April 2018
Beginner to intermediate
440 pages
11h 36m
English
Generating the database table is made possible by the Chapter12_0.py script, which creates a PostgreSQL database called chapter12 and adds spatial functionality to the new database. Adjust the credentials, host, and port (as needed) in the connection configuration below.
Connect to the database server using psycopg2 and its connect function, which creates a connection class. The class has a cursor function that creates a cursor object, which is able to execute SQL statements. This section creates the database for the chapter:
import psycopg2connection = psycopg2.connect(host='localhost', user='{user}',password='{password}', port="5432")connection.autocommit = Truecursor = connection.cursor()cursor.execute('CREATE DATABASE ...