Skip to Content
Building RESTful Web services with Go
book

Building RESTful Web services with Go

by Naren Yellavula
December 2017
Intermediate to advanced
316 pages
6h 58m
English
Packt Publishing
Content preview from Building RESTful Web services with Go

pq, a pure PostgreSQL database driver for Go

In the previous chapters when we dealt with SQLite3, we used an external library called go-sqlite3. In the same way, a database driver library is available to bridge both Go and PostgreSQL. That library is called pq. We can install that library using the command:

go get github.com/lib/pq

After getting this library, we need to use it in a similar way to SQLite3. The API will be in line to the database/sql package of Go. In order to create a new table, we should initialize the DB. To create a new database, just type this command from the psql shell, as shown in the following command; it is a one-time thing:

CREATE DATABASE mydb;

Now, we will write a small code illustration that explains the usage ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RESTful Web Services with Go - Second Edition

Hands-On RESTful Web Services with Go - Second Edition

Naren Yellavula
Microservices with Go

Microservices with Go

Alexander Shuiskov

Publisher Resources

ISBN: 9781788294287Supplemental Content