-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsycopg2_scratchpad.py
More file actions
36 lines (27 loc) · 792 Bytes
/
psycopg2_scratchpad.py
File metadata and controls
36 lines (27 loc) · 792 Bytes
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
import importlib.util
import sys
import os
_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
_REPOSITORY_ROOT = os.path.abspath(
os.path.join(
_THIS_DIR,
"..",
"..",
".."
)
)
spec = importlib.util.spec_from_file_location(
"module.name",
os.path.join(
_REPOSITORY_ROOT,
"test/robot/lib/psycopg2_client.py"
)
)
foo = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = foo
spec.loader.exec_module(foo)
psycopg2_client = foo.PsycoPG2Client("host=127.0.0.1 port=5466 user=silly dbname=silly")
rv = psycopg2_client.run_queries(["show transaction isolation level"])
print(rv)
rv = psycopg2_client.run_queries(["SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = 'hstore'"])
print(rv)