MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / main

Function main

code/IO/postgres_crud.py:82–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 print(f'Did: {delete_cmd}')
81
82def main():
83 try:
84 conn = psycopg2.connect( host="413.198.155.245",
85 user="al", password="SuperSecret",
86 database="pet_store")
87 except psycopg2.OperationalError as e:
88 print(f'Failed to connect: {e}')
89 return
90 cur = conn.cursor()
91
92 # drop the table 'myvalues' if it already exists
93 try:
94 cur.execute('drop table myvalues')
95 except:
96 pass
97
98 populate_table(conn, cur)
99 query_results(cur)
100
101 rename_pets(cur, 'bunny', 'rabbit')
102 query_results(cur)
103
104 remove_pets(cur, 'cat')
105 query_results(cur)
106
107 cur.execute('drop table myvalues')
108
109 conn.close()
110if __name__ == "__main__": main()

Callers 1

postgres_crud.pyFile · 0.70

Calls 4

populate_tableFunction · 0.85
query_resultsFunction · 0.85
rename_petsFunction · 0.85
remove_petsFunction · 0.85

Tested by

no test coverage detected