MCPcopy Create free account
hub / github.com/dolthub/doltgresql / main

Function main

testing/postgres-client-tests/python/sqlalchemy-test.py:30–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28
29
30def main():
31 user = sys.argv[1]
32 port = int(sys.argv[2])
33
34 conn_string_base = "postgresql+psycopg2://"
35
36 engine = create_engine(conn_string_base +
37 "{user}:password@127.0.0.1:{port}/postgres".format(user=user,
38 port=port)
39 )
40
41 with engine.connect() as con:
42 for query_response in QUERY_RESPONSE:
43 query = list(query_response.keys())[0]
44 exp_results = query_response[query]
45
46 result_proxy = con.execute(text(query))
47
48 try:
49 results = result_proxy.fetchall()
50 if (results != exp_results) and ("dolt_commit" not in query) and ("dolt_merge" not in query):
51 print("Query:")
52 print(query)
53 print("Expected:")
54 print(exp_results)
55 print("Received:")
56 print(results)
57 sys.exit(1)
58 # You can't call fetchall on an insert
59 # so we'll just ignore the exception
60 except sqlalchemy.exc.ResourceClosedError:
61 pass
62
63 con.close()
64 sys.exit(0)
65
66
67main()

Callers 1

sqlalchemy-test.pyFile · 0.70

Calls 2

textTypeAlias · 0.85
closeMethod · 0.80

Tested by

no test coverage detected