在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:jackc/pgx开源软件地址:https://github.com/jackc/pgx开源编程语言:Go 99.5%开源软件介绍:pgx - PostgreSQL Driver and Toolkitpgx is a pure Go driver and toolkit for PostgreSQL. pgx aims to be low-level, fast, and performant, while also enabling PostgreSQL-specific features that the standard The driver component of pgx can be used alongside the standard The toolkit component is a related set of packages that implement PostgreSQL functionality such as parsing the wire protocol and type mapping between PostgreSQL and Go. These underlying packages can be used to implement alternative drivers, proxies, load balancers, logical replication clients, etc. The current release of Example Usagepackage main
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v4"
)
func main() {
// urlExample := "postgres://username:password@localhost:5432/database_name"
conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
os.Exit(1)
}
defer conn.Close(context.Background())
var name string
var weight int64
err = conn.QueryRow(context.Background(), "select name, weight from widgets where id=$1", 42).Scan(&name, &weight)
if err != nil {
fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
os.Exit(1)
}
fmt.Println(name, weight)
} See the getting started guide for more information. Choosing Between the pgx and database/sql InterfacesIt is recommended to use the pgx interface if:
The pgx interface is faster and exposes more features. The Featurespgx supports many features beyond what is available through
PerformanceThere are three areas in particular where pgx can provide a significant performance advantage over the standard
Testingpgx tests naturally require a PostgreSQL database. It will connect to the database specified in the Example Test EnvironmentConnect to your PostgreSQL server and run:
Connect to the newly-created database and run:
Now, you can run the tests:
In addition, there are tests specific for PgBouncer that will be executed if Supported Go and PostgreSQL Versionspgx supports the same versions of Go and PostgreSQL that are supported by their respective teams. For Go that is the two most recent major releases and for PostgreSQL the major releases in the last 5 years. This means pgx supports Go 1.16 and higher and PostgreSQL 10 and higher. pgx also is tested against the latest version of CockroachDB. Version Policypgx follows semantic versioning for the documented public API on stable releases. PGX Family Librariespgx is the head of a family of PostgreSQL libraries. Many of these can be used independently. Many can also be accessed from pgx for lower-level control. github.com/jackc/pgconn
github.com/jackc/pgx/v4/pgxpool
github.com/jackc/pgx/v4/stdlibThis is a github.com/jackc/pgtypeOver 70 PostgreSQL types are supported including github.com/jackc/pgproto3pgproto3 provides standalone encoding and decoding of the PostgreSQL v3 wire protocol. This is useful for implementing very low level PostgreSQL tooling. github.com/jackc/pglogreplpglogrepl provides functionality to act as a client for PostgreSQL logical replication. github.com/jackc/pgmockpgmock offers the ability to create a server that mocks the PostgreSQL wire protocol. This is used internally to test pgx by purposely inducing unusual errors. pgproto3 and pgmock together provide most of the foundational tooling required to implement a PostgreSQL proxy or MitM (such as for a custom connection pooler). github.com/jackc/terntern is a stand-alone SQL migration system. github.com/jackc/pgerrcodepgerrcode contains constants for the PostgreSQL error codes. 3rd Party Libraries with PGX Supportgithub.com/georgysavva/scanyLibrary for scanning data from a database into Go structs and more. https://github.com/otan/gopgkrb5Adds GSSAPI / Kerberos authentication support. https://github.com/vgarvardt/pgx-google-uuidAdds support for |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论