Questions tagged [pgx]

pgx is a pure Go driver and toolkit for PostgreSQL.

Go module github.com/jackc/pgx is a pure Go driver and toolkit for PostgreSQL.

119 questions
2
votes
0 answers

GO dynamic update queries with Gin and PGX

I'm trying to build a web service which would receive an HTTP PATCH request to update some fields in a "users" table (so I don't know how many nor which ones have to be updated). I decided to work with Gin and because I'm working with Postgres, I'm…
Big_Boulard
  • 799
  • 1
  • 13
  • 28
2
votes
0 answers

How to force closing pgxpool.Pool while queries are still running

I'm implementing graceful termination for a Golang Application deployed on a Kubernetes cluster. I'm using pgxconn.Pool. My main challenge now is to forcefully kill all queries from the Application that are running on the PostgreSQL server during…
Alechko
  • 1,406
  • 1
  • 13
  • 27
2
votes
1 answer

Golang query scan not scanning query correctly into struct

I am having trouble with scanning from a pgx query in Golang. The id field is always that of the last record. If I un-comment the var person Person declaration at the top of the function, every id is 3. There are 3 records with id's from 1 to 3 in…
markhorrocks
  • 1,199
  • 19
  • 82
  • 151
2
votes
1 answer

AWS RDS Proxy not closing DB Connections on its own

Using pgxpool as an import for Client Side Pooling, also using RDS Proxy for pooling Folder Structure database pghelper.go (here used singleton pgxPool.ConnectConfig(ctx, config) and returning connect instance to all the…
2
votes
1 answer

How to build a query with an optional filter resistant to SQL injections?

There is such a database: And such a stored function: CREATE FUNCTION fetch_mentor(direction_type_list_in text, education_type_list_in text, name_in text, city_id_in integer) RETURNS json LANGUAGE plpgsql AS $$ DECLARE …
wisicoc
  • 73
  • 1
  • 6
2
votes
1 answer

postgres enum with golang pgx

Let's say I have a micro-service in golang using pgx to connect to postgres database. I have a data structure that has a enum type: CREATE TYPE "direction_type" AS ENUM ( 'LEFT', 'RIGHT', 'UP', 'DOWN' ); CREATE TABLE "move_log" ( ID…
ton
  • 3,827
  • 1
  • 42
  • 40
2
votes
1 answer

PlaceHolderFormat doesn't replace the dollar sign for the parameter value during SQL using pgx driver for postgres

I am new to Go and am trying to check a password against a username in a postgresql database. I can't get dollar substitution to occur and would rather not resort to concatenating strings. I am currently using squirrel but also tried it without and…
Paul Ryan
  • 119
  • 8
2
votes
0 answers

How to get multiple hosts configuration and database cluster failover

In java we had an option to use multiple hosts configuration with failover mechanism: jdbc:postgresql://node1:port1,node2:port2,node3:port3/accounting?targetServerType=primary do we have such support in Go? How the connection string should look…
2
votes
1 answer

Migrating problem using psql array for pq to pgx

Here is my old code: cardinalPoints := []string{"75101", "75110", "75112", "75115", "92062"} query = `SELECT * FROM "DataCom_travel" WHERE ((com1 = $1 AND com2 IN ($2)) OR (com1 IN ($2) AND com2 = $1));` err := db.Select(&dataComTravel, query,…
Bussiere
  • 500
  • 13
  • 60
  • 119
2
votes
1 answer

"wrong element type" when using JSONBArray using pgx

I am trying to insert a new row that has an inventory with data type jsonb[]: elements := []pgtype.Text{{String: `{"adsda": "asdasd"}`, Status: pgtype.Present}} dimensions := []pgtype.ArrayDimension{{Length: 1, LowerBound: 1}} inventory :=…
dclipca
  • 1,739
  • 1
  • 16
  • 51
2
votes
1 answer

PostGIS rows are being inserted as hexadecimal WKT inside Postgres

As seen in the following function, I am trying to insert rows into the building table. Everything works except that instead of being saved as normal text, the coordinate is saved as WKB (as shown in the screenshot and sample). func (db Database)…
dclipca
  • 1,739
  • 1
  • 16
  • 51
2
votes
0 answers

Cannot determine the type of a Point from PostGIS in Postgres (Golang with the pgx library)

I am using Go with the pgx library to query from a Postgres database with the PostGIS plugin but I am not able to determine the type of Point from PostGIS, or better said, into what type does it fit in Golang. Code: rows, err :=…
dclipca
  • 1,739
  • 1
  • 16
  • 51
2
votes
0 answers

Extracting array data from JSONB column in PostgreSQL and Marshaling it to slice of string In Go using pgx library

I somehow managed to make this works , but not exactly as intended. Code below is "poco" for data in JSONB column. type post struct { Title string `json:"title"` Tags []string `json:"tags"` } Below i have initialization of…
Seth
  • 31
  • 4
2
votes
1 answer

Pgx OutOfMemoryError: maximum off-heap size is configured to not exceed 8,192 MBs

I'm having a problem with the PGX API of Oracle. I loaded a big graph and I apply successive filters, but after computing some calculations I destroy the temporaries graphs. GraphChangeSet subGraphChangeSet =…
fingerprints
  • 2,751
  • 1
  • 25
  • 45
1
vote
1 answer

Graceful shutdown of golang web server

I'm trying to find an optimal way to handle ongoing PostgreSQL transactions during the shutdown of a golang server running on Kubernetes. Does it make sense to wait for transactions to finish, when these transaction are serving requests initiated by…
Alechko
  • 1,406
  • 1
  • 13
  • 27