import psycopg2
conn = psycopg2.connect("dbname='template1' user='dbuser' host='localhost' password='dbpass'")
cur = conn.cursor()
Once you have the cursor of the database, you can execute queries with:
cr.execute(your_query;)
Source: https://wiki.postgresql.org/wiki/Psycopg2_Tutorial
Comments
Comments powered by Disqus