forked from Marshh/SupportGroupConnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printEverything.py
58 lines (52 loc) · 1.21 KB
/
printEverything.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import psycopg2
import sys
con = None
try:
con = psycopg2.connect("host='localhost' dbname='supportGroupConnect' user='postgres' password='password'")
cur = con.cursor()
cur.execute("SELECT * FROM users")
row = cur.fetchone()
print("User Table")
while row != None:
print(row)
row = cur.fetchone()
cur.execute("SELECT * FROM friends")
row = cur.fetchone()
print("\n Friend Table")
while row != None:
print(row)
row = cur.fetchone()
cur.execute("SELECT * FROM condition")
row = cur.fetchone()
print("\n Condition Table")
while row != None:
print(row)
row = cur.fetchone()
cur.execute("SELECT * FROM messages")
row = cur.fetchone()
print("\n Message Table")
while row != None:
print(row)
row = cur.fetchone()
cur.execute("SELECT * FROM groups")
row = cur.fetchone()
print("\n Groups Table")
while row != None:
print(row)
row = cur.fetchone()
cur.execute("SELECT * FROM memberships")
row = cur.fetchone()
print("\n Memberships Table")
while row != None:
print(row)
row = cur.fetchone()
con.commit()
except psycopg2.DatabaseError as e:
if con:
con.rollback()
print("printing error...")
print ('Error %s' % e )
sys.exit(1)
finally:
if con:
con.close()