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 [2025/03/08 22:24] (current) – external edit 127.0.0.1
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: 2025/03/08 22:23 (external edit)