Skip to content
Docs
Modules
pgx

pgx

Module pgx provides PostgreSQL functionality from the pgx (opens in a new tab) library.

Functions

connect

Function signature
connect(dsn string) conn

Connect to the database specified by the dsn string.

Example
>>> conn := pgx.connect("postgres://user:pass@localhost:5432/db")
>>> conn.query("SELECT * FROM users")
[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
>>> conn.close()

Types

conn

Represents a connection to a PostgreSQL database.

Attributes

NameTypeDescription
queryfunc(sql string, args ...object) listReturn a list of records generated by the query
closefunc()Close the connection