-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcore.py
More file actions
178 lines (175 loc) · 3.66 KB
/
core.py
File metadata and controls
178 lines (175 loc) · 3.66 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
"""Core functionality from extension module."""
try:
from ._pg import version
except ImportError as e: # noqa: F841
import os
libpq = 'libpq.'
if os.name == 'nt':
libpq += 'dll'
paths = [path for path in os.environ["PATH"].split(os.pathsep)
if os.path.exists(os.path.join(path, libpq))]
# see https://docs.python.org/3/whatsnew/3.8.html#ctypes
add_dll_dir = os.add_dll_directory # type: ignore
for path in paths:
with add_dll_dir(os.path.abspath(path)):
try:
from ._pg import version
except ImportError:
pass
else:
del version
e = None # type: ignore
break
if paths:
libpq = 'compatible ' + libpq
else:
libpq += 'so'
if e:
raise ImportError(
"Cannot import shared library for PyGreSQL,\n"
f"probably because no {libpq} is installed.\n{e}") from e
else:
del version
# import objects from extension module
from ._pg import (
INV_READ,
INV_WRITE,
POLLING_FAILED,
POLLING_OK,
POLLING_READING,
POLLING_WRITING,
RESULT_DDL,
RESULT_DML,
RESULT_DQL,
RESULT_EMPTY,
SEEK_CUR,
SEEK_END,
SEEK_SET,
TRANS_ACTIVE,
TRANS_IDLE,
TRANS_INERROR,
TRANS_INTRANS,
TRANS_UNKNOWN,
Connection,
DatabaseError,
DataError,
Error,
IntegrityError,
InterfaceError,
InternalError,
InvalidResultError,
LargeObject,
MultipleResultsError,
NoResultError,
NotSupportedError,
OperationalError,
ProgrammingError,
Query,
Warning,
cast_array,
cast_hstore,
cast_record,
connect,
escape_bytea,
escape_string,
get_array,
get_bool,
get_bytea_escaped,
get_datestyle,
get_decimal,
get_decimal_point,
get_defbase,
get_defhost,
get_defopt,
get_defport,
get_defuser,
get_jsondecode,
get_pqlib_version,
set_array,
set_bool,
set_bytea_escaped,
set_datestyle,
set_decimal,
set_decimal_point,
set_defbase,
set_defhost,
set_defopt,
set_defpasswd,
set_defport,
set_defuser,
set_jsondecode,
set_query_helpers,
unescape_bytea,
version,
)
__all__ = [
'INV_READ',
'INV_WRITE',
'POLLING_FAILED',
'POLLING_OK',
'POLLING_READING',
'POLLING_WRITING',
'RESULT_DDL',
'RESULT_DML',
'RESULT_DQL',
'RESULT_EMPTY',
'SEEK_CUR',
'SEEK_END',
'SEEK_SET',
'TRANS_ACTIVE',
'TRANS_IDLE',
'TRANS_INERROR',
'TRANS_INTRANS',
'TRANS_UNKNOWN',
'Connection',
'DataError',
'DatabaseError',
'Error',
'IntegrityError',
'InterfaceError',
'InternalError',
'InvalidResultError',
'LargeObject',
'MultipleResultsError',
'NoResultError',
'NotSupportedError',
'OperationalError',
'ProgrammingError',
'Query',
'Warning',
'cast_array',
'cast_hstore',
'cast_record',
'connect',
'escape_bytea',
'escape_string',
'get_array',
'get_bool',
'get_bytea_escaped',
'get_datestyle',
'get_decimal',
'get_decimal_point',
'get_defbase',
'get_defhost',
'get_defopt',
'get_defport',
'get_defuser',
'get_jsondecode',
'get_pqlib_version',
'set_array',
'set_bool',
'set_bytea_escaped',
'set_datestyle',
'set_decimal',
'set_decimal_point',
'set_defbase',
'set_defhost',
'set_defopt',
'set_defpasswd',
'set_defport',
'set_defuser',
'set_jsondecode',
'set_query_helpers',
'unescape_bytea',
'version',
]