User Tools

Site Tools


pythonpostgresql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
pythonpostgresql [2021/11/29 22:10] – z0hpvkpythonpostgresql [2021/12/06 11:33] (current) – z0hpvk
Line 81: Line 81:
 import conndetails as creds import conndetails as creds
  
-conn_string = "host="+ creds.PGHOST +" port="+ "5432" +" dbname="+ creds.PGDATABASE \ +conn_string = "host="+ creds.PGHOST +" dbname="+ creds.PGDATABASE +" user="  
-             +" user=" + creds.PGUSER +" password="+ creds.PGPASSWORD+               + creds.PGUSER +" password="+ creds.PGPASSWORD
 conn = psycopg2.connect(conn_string) conn = psycopg2.connect(conn_string)
 +
 +cur = conn.cursor()
 +query = "select version()"
 +cur.execute(query)
 +for row in cur:
 +  print(row)
 +
 +cur.close() 
 </code> </code>
  
pythonpostgresql.1638223814.txt.gz · Last modified: (external edit)