Sfoglia il codice sorgente

Template for connection

Jovian (Netbook) 6 anni fa
parent
commit
8da72a01fc
1 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. 15 0
      connect.py

+ 15 - 0
connect.py

@@ -0,0 +1,15 @@
+import psycopg2
+
+conn = psycopg2.connect("host=myHost dbname=myDB user=xxx password=yyy")
+
+cursor = conn.cursor()
+
+cursor.execute("SELECT * from person")
+
+rows = cursor.fetchall()
+
+for row in rows:
+	print(row)
+
+cursor.close()
+conn.close()