-
Book Overview & Buying
-
Table Of Contents
Practical Systems Programming in Go
By :
PostgreSQL is a powerful, production-grade relational database that offers advanced features such as transactions, indexing, and concurrency control. In this section, we will build on what you learned with SQLite3 to connect Go programs to PostgreSQL databases, execute queries, and perform CRUD operations. The PostgreSQL version of the Go program is very similar to the SQLite3 version in terms of overall structure and logic. Both programs define the same set of functions for connecting to the database — inserting, querying, updating, deleting, and using prepared statements — and they both rely on the database/sql interface. The main differences are localized to the connectDB() function and the connection string it uses. For PostgreSQL, the program connects to a server using either the pgx or postgres driver with a network-based URL including credentials and database name. Beyond this, minor adjustments may be needed in the table creation SQL to match...