TIL: Non Standard Postgres Types in Livebook

TIL: Non Standard Postgres Types in Livebook

Table of Contents

Livebook has a new, nice feature that allows you to connect to a database. It works with basic data types.

livebook screenshot

But I found a problem when the data type is not supported by postgrex. livebook screenshot

In this case, you can either have to write a custom postgrex extension like the example here. In postgrex GitHub repo, there are many examples for common data types, but XML is missing there.

You can also cast your field to a supported data type:

SELECT demographics::text from person.person   

livebook screenshot

To play with this example, you can install the example Adventureworks database provided by Microsoft. I made an elixir converter that converts some of the files to a format accepted by PostgreSQL, and also updated the previous version to properly name the columns with underscores.

comments powered by Disqus

Related Posts

Nginx Logs in Live Dashboard

Nginx Logs in Live Dashboard

Building on top of my previous blog posts on creating a nginx log parser and displaying ps output in live dashboard I decided to build a nginx log display.

Read More
SQL Commenter with Postgrex

SQL Commenter with Postgrex

A few years ago, I discovered sqlcommenter, a tool that enables adding trace context to SQL queries. This feature makes it possible to match database calls visible in PostgreSQL logs or any observability tool. At the time, I found several questions about this topic scattered across the internet, but no concrete solutions. I attempted to solve this myself and experimented with various approaches, but none of them proved viable for implementation in Elixir, particularly with Ecto.

Read More
Optimizing DateTime Serialization in Elixir

Optimizing DateTime Serialization in Elixir

The Journey of Optimization

A deep dive into optimizing Elixir’s Calendar module, improving datetime serialization performance through iodata and improper lists

Recently, I watched some Elixir vs Go comparison videos on YouTube. After the first comparison, José Valim made a PR to make the comparison more accurate. One key difference was that the Elixir version used Ecto and serialized datetime multiple times, while the Go version used raw SQL and single datetime serialization.

Read More