-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpostgresqlschemareader_test.py
More file actions
executable file
·46 lines (29 loc) · 1.12 KB
/
postgresqlschemareader_test.py
File metadata and controls
executable file
·46 lines (29 loc) · 1.12 KB
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
import pprint
import psycopg2
import postgresqlschemareader
def main():
"""
Test and demonstrate the functions of the postgresqlschemareader module.
"""
print("--------------------------")
print("| codedrome.com |")
print("| Read PostgreSQL Schema |")
print("--------------------------\n")
try:
conn = psycopg2.connect("dbname=codeinpython host='localhost' user='chris' password='chris'")
# tables = postgresqlschemareader.get_tables(conn)
# print("codeinpython Tables\n===================\n")
# postgresqlschemareader.print_tables(tables)
# columns = postgresqlschemareader.get_columns(conn, "public", "photos")
# print("Columns in photos Table\n=======================\n")
# postgresqlschemareader.print_columns(columns)
tree = postgresqlschemareader.get_tree(conn)
print("Database codeinpython\n=====================\n")
postgresqlschemareader.print_tree(tree)
print()
pprint.pprint(tree)
conn.close()
except psycopg2.Error as e:
print(type(e))
print(e)
main()