You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defined as query := pq.CopyIn("public.foo", "col_foo", "col_bar")
prints as COPY "public.foo" ("col_foo", "col_bar") FROM STDIN.
Executing the prepared statement
prepared via tx.Prepare(query)
tx being defined as tx, err := db.Begin()
db is of type sqlx.DB, a connection established via sqlx.Connect if that matters
via _, err := statement.Exec("foo", "bar") returns either
sql: expected 0 arguments, got 2
This occurs when I use "pgx" as the driver when establishing the connection.
pq: relation "public.foo" does not exist when preparing
This occurs when I use "postgres" (pq) as the driver when establishing the connection. and is infinitely more puzzling, because not only does the relation exist when checked manually (SELECT * FROM public.foo; works fine in Postgres shell), but the application also contains a SELECT statement that leftjoins on public.foo, which works fine and returns no errors.
I don't really see a reason for why this would happen, no relevant issues for either of the two points. I'd prefer to use pq, because pgx's CopyFrom straight up does not support usage from transactions for whatever reason and requires a direct access to connection.
Let me know if I can provide anything else to elaborate.
The text was updated successfully, but these errors were encountered:
bqback
changed the title
Exectuing pq.CopyIn fails with a variety of errors depending on usage
Exectuing pq.CopyIn fails with one of two errors depending on usage
Mar 16, 2024
Query is
query := pq.CopyIn("public.foo", "col_foo", "col_bar")
COPY "public.foo" ("col_foo", "col_bar") FROM STDIN
.Executing the prepared statement
tx.Prepare(query)
tx
being defined astx, err := db.Begin()
db
is of typesqlx.DB
, a connection established viasqlx.Connect
if that mattersvia
_, err := statement.Exec("foo", "bar")
returns eithersql: expected 0 arguments, got 2
pq: relation "public.foo" does not exist
when preparingSELECT * FROM public.foo;
works fine in Postgres shell), but the application also contains aSELECT
statement that leftjoins onpublic.foo
, which works fine and returns no errors.I don't really see a reason for why this would happen, no relevant issues for either of the two points. I'd prefer to use
pq
, becausepgx
'sCopyFrom
straight up does not support usage from transactions for whatever reason and requires a direct access to connection.Let me know if I can provide anything else to elaborate.
The text was updated successfully, but these errors were encountered: