github.com/jackc/pgx/v5@v5.5.5/pgconn/README.md (about)

     1  # pgconn
     2  
     3  Package pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level as the C library libpq.
     4  It is primarily intended to serve as the foundation for higher level libraries such as https://github.com/jackc/pgx.
     5  Applications should handle normal queries with a higher level library and only use pgconn directly when required for
     6  low-level access to PostgreSQL functionality.
     7  
     8  ## Example Usage
     9  
    10  ```go
    11  pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL"))
    12  if err != nil {
    13  	log.Fatalln("pgconn failed to connect:", err)
    14  }
    15  defer pgConn.Close(context.Background())
    16  
    17  result := pgConn.ExecParams(context.Background(), "SELECT email FROM users WHERE id=$1", [][]byte{[]byte("123")}, nil, nil, nil)
    18  for result.NextRow() {
    19  	fmt.Println("User 123 has email:", string(result.Values()[0]))
    20  }
    21  _, err = result.Close()
    22  if err != nil {
    23  	log.Fatalln("failed reading result:", err)
    24  }
    25  ```
    26  
    27  ## Testing
    28  
    29  See CONTRIBUTING.md for setup instructions.