January 2019
Beginner
556 pages
14h 19m
English
Connections to databases are handled by the objects of the connection class. These objects represent database sessions in the application. The objects are created using the connect() function from the psycopg2 module. This way of creating connections is defined by the DB-API 2.0.
To specify the location and authenticate in the database, a connection string can be used, such as this:
conn = connect("host=db_host user=some_user dbname=database " "password=$ecreT")
Alternatively, named parameters can be used, such as this:
conn = connect(host="db_host", user="some_user", dbname="database", password="$ecreT")
Here, the connection would be established to the database named database, located at the db_host server as the ...
Read now
Unlock full access