Links:
go get
to download the driver:$ go get github.com/lib/pq@v1
blank identifier
:package main
import "_ github.com/lib/pq"
The Postgres data source name (DSN) uses the following format:
postgres://<username>:<password>@<host>/<dbname>
If you set the DSN as an environment variable, you can use it to authenticate to the database:
$ psql $POSTGRES_DSN_ENV_VAR
PostgreSQL uses meta commands, such as /dt <table-name>
.
pq.Array()
method
You can add logic to your queries with array functions and operators.
For example, the @>
operator checks whether an array contains a value. The following expression returns true
if the genres
array contains the value that the $2
placeholder represents, or if the placeholder is empty:
(genres @> $2 OR $2 = '{}')