Skip to content

DrakoRod/pgx-rowstojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DrakoHacks

pgx-rowstojson

Is a simple example to convert a PostgreSQL query rows to json using pgxv4 driver. The main function is based in this stackoverflow question.

Execute the example

Just clone project and change database connection settings like this:

$ git clone https://github.com/DrakoRod/pgx-rowstojson 
$ cd pgx-rowstojson/

Change database connections settings in code

urlExample := "postgres://postgres:s3cr3t@localhost:5432/postgres"

Execute main.go to test

$ go run main.go
JSON Result::>  [{"datname":"template1","datowner":"postgres"},{"datname":"template0","datowner":"postgres"},{"datname":"explain","datowner":"drakorod"}{"datname":"drakorod","datowner":"drakorod"},{"datname":"go_project","datowner":"corvus_user"}]

Enjoy! :)

About

Is a simple example to convert a PostgreSQL query rows to json using pgx v4 in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages