Questions tagged [postgrex]

For questions related to PostgreSQL driver for Elixir.

postgrex is a driver for .

Features:

  • Automatic decoding and encoding of Elixir values to and from PostgreSQL's binary format
  • User defined extensions for encoding and decoding any PostgresSQL type
  • Supports transactions, prepared queries and multiple pools via DBConnection
  • Supports PostgreSQL 8.4, 9.0, 9.1, 9.2, 9.3, 9.4, and 9.5 (hstore is not supported on 8.4)

Additional links:

32 questions
12
votes
3 answers

Ecto unique constraint error on pkey

I started getting the following error when trying to insert a new room ** (Ecto.ConstraintError) constraint error when attempting to insert struct: * unique: rooms_pkey If you would like to convert this constraint into an error, please call…
Katherine
  • 2,086
  • 1
  • 14
  • 23
7
votes
2 answers

Phoenix / Elixir testing when setting isolation level of transaction

I have a chunk of code that looks something like this: Repo.transaction(fn -> Repo.query!("set transaction isolation level serializable;") # do some queries end) In my test suite, I continually run into the error: (Postgrex.Error) ERROR…
astjohn
  • 2,922
  • 1
  • 22
  • 25
6
votes
1 answer

Use Ecto to generate_series in postgres and also retrieve Null-values as “0”

I want to display a range of dates (statistics) like: Dates | Count -------------------- "2016-09-01" | 0 "2016-09-02" | 0 "2016-09-03" | 0 "2016-09-04" | 0 "2016-09-05" | 0 "2016-09-06" | 12 "2016-09-07" | 9 "2016-09-08" | 0 "2016-09-09" |…
kayne
  • 349
  • 2
  • 15
4
votes
1 answer

Postgrex.Error ERROR 42501 insufficient_privilege to create extension citext

I am trying to create a migration. this is the output MIX_ENV=prod DATABASE_URL="URL" mix ecto.migrate [info] execute "CREATE EXTENSION citext;" ** (Postgrex.Error) ERROR 42501 (insufficient_privilege): permission denied to create extension…
user2290820
  • 2,709
  • 5
  • 34
  • 62
4
votes
1 answer

How to disconnect Postgrex connection?

I'm trying to figure out how to connect to a postgres database, run a query, and then disconnect. Looking at Postgrex, I establish a connection using {:ok, pid} = Postgrex.start_link(hostname: "localhost", username: "postgres", password:…
Jesse Shieh
  • 4,660
  • 5
  • 34
  • 49
3
votes
1 answer

Type `_geometry` can not be handled by the types module

I'm trying to set up Postgis with Ecto, i've been following the documentation of https://github.com/bryanjos/geo_postgis closely. But when trying to retrieve a resource that has the following field field :coords, {:array, Geo.PostGIS.Geometry},…
MartinElvar
  • 5,695
  • 6
  • 39
  • 56
3
votes
1 answer

How do I prevent a cumbersome query from timing out in Postgrex?

I'm running a query and loading the results into a Stream using Postgrex, like so: {:ok, host_pid} = Postgrex.start_link(hostname: "somewhere.hostname.io", username: "myuser", password: "mypass", database: "mydb") Postgrex.transaction(host_pid,…
Alex V
  • 3,416
  • 2
  • 33
  • 52
3
votes
0 answers

Unable to create array of Geo.Point in Phoenix Elixir Postgres

I am attempting to create an array of Geo Point objects in postgres in phoenix elixir. I get the error type _geometry can not be handled by the types module Terror.PostgrexType. In Terror.Postgrextype:…
2
votes
2 answers

Elixir postgrex with poolboy example on Windows fails with 'module DBConnection.Poolboy not available'

I am exploring using Elixir for fast Postgres data imports of mixed types (CSV, JSON). Being new to Elixir, I am following the the example given in the youtube video "Fast Import and Export with Elixir and Postgrex - Elixir Hex package showcase"…
HLampert
  • 33
  • 3
2
votes
1 answer

Using a table alias/query expression in an Ecto fragment?

Starting with this query as the basis for an Ecto version: select folder_id, json_agg(p.*) from folder_memberships inner join profiles p on p.id=folder_memberships.profile_id where folder_id in (1234) group by folder_id; I've got this code: …
Keith Gaddis
  • 4,113
  • 23
  • 20
2
votes
2 answers

Phoenix Repo with no database generates too many logs

I have a Phoenix repository that other engineers clone when creating a new app. I have the following in the prod.exs config :foo, Foo.Repo, adapter: Ecto.Adapters.Postgres, url: {:system, "DATABASE_URL"}, pool_size: 1 The engineer normally…
Jesse Shieh
  • 4,660
  • 5
  • 34
  • 49
2
votes
1 answer

Error trying to implement "geo" postgrex extention type

I'm following this tutorial which adds a postgrex extension into the config.exs with the extensions field. However that is now a deprecated way to add a postgrex extension, we should now use the type field instead of the extensions field. I'm…
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
2
votes
1 answer

Elixir, error with postgresql: has invalid types for the connection

I'm getting the following issue: ArgumentError{message: \"query %Postgrex.Query{columns: ["id", "name", "internal", "inserted_at", "updated_at"], name: "ecto_616034", param_formats: [:binary], param_oids: [25], param_types:…
Otto
  • 88
  • 6
1
vote
1 answer

Querying jsonb field with @> through Postgrex adapter

I'm trying to query jsonb field via Postgrex adapter, however I receive errors I cannot understand. Notification schema def all_for(user_id, external_id) do from(n in __MODULE__, where: n.to == ^user_id and fragment("? @> '{\"external_id\":…
zhisme
  • 2,368
  • 2
  • 19
  • 28
1
vote
0 answers

Cleanup ExUnit from within the same process (unlike on_exit)

In our codebase, we have lots of tests that involve interacting with the database (via Postgrex). We have a handful of shared ExUnit.CaseTemplates whose setup hook prepares the Ecto sandbox and such, and this works great. The problem I'm running…
s3cur3
  • 2,749
  • 2
  • 27
  • 42
1
2 3