initial commit
This commit is contained in:
commit
6150895b86
9 changed files with 945 additions and 0 deletions
27
testconn.py
Normal file
27
testconn.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# https://www.postgresqltutorial.com/postgresql-python/connect/
|
||||
|
||||
import psycopg
|
||||
from config import config
|
||||
|
||||
conn = None
|
||||
|
||||
try:
|
||||
params = config()
|
||||
conn = psycopg.connect(**params)
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"SELECT * from main LIMIT 10"
|
||||
)
|
||||
# cur.fetchone()
|
||||
for record in cur:
|
||||
print(record)
|
||||
conn.commit()
|
||||
cur.close()
|
||||
except (Exception, psycopg.DatabaseError) as error:
|
||||
print(error)
|
||||
finally:
|
||||
if conn is not None:
|
||||
conn.close()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue