psycopg

The most widely used Python driver for PostgreSQL databases.

In more detail

Code opens a connection, gets a cursor from it and runs queries with cursor.execute. Its cursor.execute takes SQL text and, separately, a tuple of parameters; passing values that way prevents SQL injection.

Example

conn = psycopg.connect("host=db dbname=postgres user=postgres password=secret")

Related terms

Taught in

References