The cursor class — Psycopg 2.9.3 documentation
https://www.psycopg.org/docs/cursor.htmlThe cursor class¶ class cursor¶. Allows Python code to execute PostgreSQL command in a database session. Cursors are created by the connection.cursor() method: they are bound to the connection for the entire lifetime and all the commands are executed in the context of the database session wrapped by the connection.. Cursors created from the same connection are not …
Basic module usage — Psycopg 2.9.3 documentation
https://www.psycopg.org/docs/usage.html>>> import psycopg2 # Connect to an existing database >>> conn = psycopg2. connect ("dbname=test user=postgres") # Open a cursor to perform database operations >>> cur = conn. cursor # Execute a command: this creates a new table >>> cur. execute ("CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);") # Pass data to fill a query placeholders and let ...