PyGreSQL 6.3.0b1__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pg/__init__.py +192 -0
- pg/_pg.cp315-win_amd64.pyd +0 -0
- pg/_pg.pyi +739 -0
- pg/adapt.py +1033 -0
- pg/attrs.py +29 -0
- pg/cast.py +544 -0
- pg/core.py +180 -0
- pg/db.py +1557 -0
- pg/error.py +59 -0
- pg/helpers.py +283 -0
- pg/notify.py +158 -0
- pg/py.typed +4 -0
- pg/tz.py +21 -0
- pgdb/__init__.py +153 -0
- pgdb/adapt.py +329 -0
- pgdb/cast.py +775 -0
- pgdb/connect.py +73 -0
- pgdb/connection.py +164 -0
- pgdb/constants.py +14 -0
- pgdb/cursor.py +861 -0
- pgdb/py.typed +1 -0
- pgdb/typecode.py +40 -0
- pygresql-6.3.0b1.dist-info/METADATA +81 -0
- pygresql-6.3.0b1.dist-info/RECORD +27 -0
- pygresql-6.3.0b1.dist-info/WHEEL +5 -0
- pygresql-6.3.0b1.dist-info/licenses/LICENSE.txt +30 -0
- pygresql-6.3.0b1.dist-info/top_level.txt +2 -0
pg/_pg.pyi
ADDED
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
"""Type hints for the PyGreSQL C extension."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
6
|
+
from os import PathLike
|
|
7
|
+
from typing import Any, SupportsIndex, TypeAlias, TypeVar, final, overload
|
|
8
|
+
|
|
9
|
+
# stub-only helpers (private, so that they are not checked by stubtest)
|
|
10
|
+
_AnyStr = TypeVar('_AnyStr', str, bytes, str | bytes)
|
|
11
|
+
_SomeNamedTuple: TypeAlias = Any # alias for accessing arbitrary named tuples
|
|
12
|
+
_StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes]
|
|
13
|
+
# column names as list or tuple of str or bytes (lists are invariant)
|
|
14
|
+
_ColumnNames: TypeAlias = (list[str] | list[bytes] | list[str | bytes]
|
|
15
|
+
| tuple[str | bytes, ...])
|
|
16
|
+
|
|
17
|
+
version: str
|
|
18
|
+
__version__: str
|
|
19
|
+
|
|
20
|
+
RESULT_EMPTY: int
|
|
21
|
+
RESULT_DML: int
|
|
22
|
+
RESULT_DDL: int
|
|
23
|
+
RESULT_DQL: int
|
|
24
|
+
|
|
25
|
+
TRANS_IDLE: int
|
|
26
|
+
TRANS_ACTIVE: int
|
|
27
|
+
TRANS_INTRANS: int
|
|
28
|
+
TRANS_INERROR: int
|
|
29
|
+
TRANS_UNKNOWN: int
|
|
30
|
+
|
|
31
|
+
POLLING_OK: int
|
|
32
|
+
POLLING_FAILED: int
|
|
33
|
+
POLLING_READING: int
|
|
34
|
+
POLLING_WRITING: int
|
|
35
|
+
|
|
36
|
+
INV_READ: int
|
|
37
|
+
INV_WRITE: int
|
|
38
|
+
|
|
39
|
+
SEEK_SET: int
|
|
40
|
+
SEEK_CUR: int
|
|
41
|
+
SEEK_END: int
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Error(Exception):
|
|
45
|
+
"""Exception that is the base class of all other error exceptions."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Warning(Exception): # noqa: N818
|
|
49
|
+
"""Exception raised for important warnings."""
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class InterfaceError(Error):
|
|
53
|
+
"""Exception raised for errors related to the database interface."""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class DatabaseError(Error):
|
|
57
|
+
"""Exception raised for errors that are related to the database."""
|
|
58
|
+
|
|
59
|
+
sqlstate: str | None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class InternalError(DatabaseError):
|
|
63
|
+
"""Exception raised when the database encounters an internal error."""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class OperationalError(DatabaseError):
|
|
67
|
+
"""Exception raised for errors related to the operation of the database."""
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ConnectError(OperationalError, InternalError):
|
|
71
|
+
"""Exception raised when a connection cannot be established."""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class ProgrammingError(DatabaseError):
|
|
75
|
+
"""Exception raised for programming errors."""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class IntegrityError(DatabaseError):
|
|
79
|
+
"""Exception raised when the relational integrity is affected."""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class DataError(DatabaseError):
|
|
83
|
+
"""Exception raised for errors due to problems with the processed data."""
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class NotSupportedError(DatabaseError):
|
|
87
|
+
"""Exception raised when a method or database API is not supported."""
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class InvalidResultError(DataError):
|
|
91
|
+
"""Exception when a database operation produced an invalid result."""
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class NoResultError(InvalidResultError):
|
|
95
|
+
"""Exception when a database operation did not produce any result."""
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class MultipleResultsError(InvalidResultError):
|
|
99
|
+
"""Exception when a database operation produced multiple results."""
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@final
|
|
103
|
+
class Notice:
|
|
104
|
+
"""Notice object passed to notice receivers.
|
|
105
|
+
|
|
106
|
+
This type is not available as a module attribute.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
pgcnx: Connection | None
|
|
110
|
+
message: str
|
|
111
|
+
severity: str
|
|
112
|
+
primary: str
|
|
113
|
+
detail: str | None
|
|
114
|
+
hint: str | None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@final
|
|
118
|
+
class Source:
|
|
119
|
+
"""Source object.
|
|
120
|
+
|
|
121
|
+
This type is not available as a module attribute.
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
pgcnx: Connection
|
|
125
|
+
arraysize: int
|
|
126
|
+
resulttype: int
|
|
127
|
+
ntuples: int
|
|
128
|
+
nfields: int
|
|
129
|
+
|
|
130
|
+
def execute(self, sql: str | bytes, /) -> int | None:
|
|
131
|
+
"""Execute a SQL statement."""
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
def fetch(self, num: int = ..., /) -> list[tuple]:
|
|
135
|
+
"""Return the next num rows from the last result in a list."""
|
|
136
|
+
...
|
|
137
|
+
|
|
138
|
+
def movefirst(self) -> None:
|
|
139
|
+
"""Move to the first result row."""
|
|
140
|
+
...
|
|
141
|
+
|
|
142
|
+
def movelast(self) -> None:
|
|
143
|
+
"""Move to the last result row."""
|
|
144
|
+
...
|
|
145
|
+
|
|
146
|
+
def movenext(self) -> None:
|
|
147
|
+
"""Move to the next result row."""
|
|
148
|
+
...
|
|
149
|
+
|
|
150
|
+
def moveprev(self) -> None:
|
|
151
|
+
"""Move to the previous result row."""
|
|
152
|
+
...
|
|
153
|
+
|
|
154
|
+
def field(self, desc: int | str | bytes, /) -> str | bytes | None:
|
|
155
|
+
"""Get the specified field value of the current row."""
|
|
156
|
+
...
|
|
157
|
+
|
|
158
|
+
def fieldinfo(self, desc: int | str | bytes, /
|
|
159
|
+
) -> tuple[int, str, int, int, int]:
|
|
160
|
+
"""Get information on the specified field."""
|
|
161
|
+
...
|
|
162
|
+
|
|
163
|
+
def listinfo(self) -> tuple[tuple[int, str, int, int, int], ...]:
|
|
164
|
+
"""Get information for all fields."""
|
|
165
|
+
...
|
|
166
|
+
|
|
167
|
+
def oidstatus(self) -> int | None:
|
|
168
|
+
"""Return oid of last inserted row (if available)."""
|
|
169
|
+
...
|
|
170
|
+
|
|
171
|
+
def putdata(self, buffer: str | bytes | BaseException | None, /
|
|
172
|
+
) -> int | None:
|
|
173
|
+
"""Send data to server during copy from stdin."""
|
|
174
|
+
...
|
|
175
|
+
|
|
176
|
+
def getdata(self, decode: bool = False, /) -> str | bytes | int:
|
|
177
|
+
"""Receive data from server during copy to stdout."""
|
|
178
|
+
...
|
|
179
|
+
|
|
180
|
+
def close(self) -> None:
|
|
181
|
+
"""Close query object without deleting it."""
|
|
182
|
+
...
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@final
|
|
186
|
+
class LargeObject:
|
|
187
|
+
"""Large object."""
|
|
188
|
+
|
|
189
|
+
oid: int | None
|
|
190
|
+
pgcnx: Connection | None
|
|
191
|
+
error: str
|
|
192
|
+
|
|
193
|
+
def open(self, mode: int, /) -> None:
|
|
194
|
+
"""Open a large object.
|
|
195
|
+
|
|
196
|
+
The valid values for 'mode' parameter are defined as the module level
|
|
197
|
+
constants INV_READ and INV_WRITE.
|
|
198
|
+
"""
|
|
199
|
+
...
|
|
200
|
+
|
|
201
|
+
def close(self) -> None:
|
|
202
|
+
"""Close a large object."""
|
|
203
|
+
...
|
|
204
|
+
|
|
205
|
+
def read(self, size: int, /) -> bytes:
|
|
206
|
+
"""Read data from large object."""
|
|
207
|
+
...
|
|
208
|
+
|
|
209
|
+
def write(self, data: bytes | str, /) -> None:
|
|
210
|
+
"""Write data to large object."""
|
|
211
|
+
...
|
|
212
|
+
|
|
213
|
+
def seek(self, offset: int, whence: int, /) -> int:
|
|
214
|
+
"""Change current position in large object.
|
|
215
|
+
|
|
216
|
+
The valid values for the 'whence' parameter are defined as the
|
|
217
|
+
module level constants SEEK_SET, SEEK_CUR and SEEK_END.
|
|
218
|
+
"""
|
|
219
|
+
...
|
|
220
|
+
|
|
221
|
+
def unlink(self) -> None:
|
|
222
|
+
"""Delete large object."""
|
|
223
|
+
...
|
|
224
|
+
|
|
225
|
+
def size(self) -> int:
|
|
226
|
+
"""Return the large object size."""
|
|
227
|
+
...
|
|
228
|
+
|
|
229
|
+
def tell(self) -> int:
|
|
230
|
+
"""Return the current position in the large object."""
|
|
231
|
+
...
|
|
232
|
+
|
|
233
|
+
def export(self, filename: _StrOrBytesPath, /) -> None:
|
|
234
|
+
"""Export a large object to a file."""
|
|
235
|
+
...
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@final
|
|
239
|
+
class Connection:
|
|
240
|
+
"""Connection object.
|
|
241
|
+
|
|
242
|
+
This object handles a connection to a PostgreSQL database.
|
|
243
|
+
It embeds and hides all the parameters that define this connection,
|
|
244
|
+
thus just leaving really significant parameters in function calls.
|
|
245
|
+
"""
|
|
246
|
+
|
|
247
|
+
host: str
|
|
248
|
+
hostaddr: str
|
|
249
|
+
port: int
|
|
250
|
+
db: str
|
|
251
|
+
options: str
|
|
252
|
+
error: str
|
|
253
|
+
status: int
|
|
254
|
+
user: str
|
|
255
|
+
protocol_version: int
|
|
256
|
+
full_protocol_version: int
|
|
257
|
+
server_version: int
|
|
258
|
+
encoding: str
|
|
259
|
+
socket: int
|
|
260
|
+
backend_pid: int
|
|
261
|
+
ssl_in_use: bool
|
|
262
|
+
ssl_attributes: dict[str, str | None]
|
|
263
|
+
|
|
264
|
+
def source(self) -> Source:
|
|
265
|
+
"""Create a new source object for this connection."""
|
|
266
|
+
...
|
|
267
|
+
|
|
268
|
+
def query(self, cmd: str | bytes, args: Sequence = ..., /) -> Query:
|
|
269
|
+
"""Create a new query object for this connection.
|
|
270
|
+
|
|
271
|
+
Note that if the command is something other than DQL, this method
|
|
272
|
+
can return an int, str or None instead of a Query.
|
|
273
|
+
"""
|
|
274
|
+
...
|
|
275
|
+
|
|
276
|
+
def send_query(self, cmd: str | bytes, args: Sequence = ..., /) -> Query:
|
|
277
|
+
"""Create a new asynchronous query object for this connection.
|
|
278
|
+
|
|
279
|
+
Note that the result methods of the query can then also return
|
|
280
|
+
an int, str or None, as described in the documentation.
|
|
281
|
+
"""
|
|
282
|
+
...
|
|
283
|
+
|
|
284
|
+
def query_prepared(self, name: str | bytes,
|
|
285
|
+
args: Sequence = ..., /) -> Query:
|
|
286
|
+
"""Execute a prepared statement."""
|
|
287
|
+
...
|
|
288
|
+
|
|
289
|
+
def prepare(self, name: str | bytes, cmd: str | bytes, /,
|
|
290
|
+
types: Sequence[SupportsIndex | None] | None = None
|
|
291
|
+
) -> None:
|
|
292
|
+
"""Create a prepared statement."""
|
|
293
|
+
...
|
|
294
|
+
|
|
295
|
+
def describe_prepared(self, name: str | bytes, /) -> Query:
|
|
296
|
+
"""Describe a prepared statement."""
|
|
297
|
+
...
|
|
298
|
+
|
|
299
|
+
def poll(self) -> int:
|
|
300
|
+
"""Complete an asynchronous connection and get its state."""
|
|
301
|
+
...
|
|
302
|
+
|
|
303
|
+
def reset(self) -> None:
|
|
304
|
+
"""Reset the connection."""
|
|
305
|
+
...
|
|
306
|
+
|
|
307
|
+
def cancel(self) -> int:
|
|
308
|
+
"""Abandon processing of current SQL command."""
|
|
309
|
+
...
|
|
310
|
+
|
|
311
|
+
def close(self) -> None:
|
|
312
|
+
"""Close the database connection."""
|
|
313
|
+
...
|
|
314
|
+
|
|
315
|
+
def fileno(self) -> int:
|
|
316
|
+
"""Get the socket used to connect to the database."""
|
|
317
|
+
...
|
|
318
|
+
|
|
319
|
+
def get_cast_hook(self) -> Callable | None:
|
|
320
|
+
"""Get the function that handles all external typecasting."""
|
|
321
|
+
...
|
|
322
|
+
|
|
323
|
+
def set_cast_hook(self, hook: Callable | None, /) -> None:
|
|
324
|
+
"""Set a function that will handle all external typecasting."""
|
|
325
|
+
...
|
|
326
|
+
|
|
327
|
+
def get_notice_receiver(self) -> Callable[[Notice], Any] | None:
|
|
328
|
+
"""Get the current notice receiver."""
|
|
329
|
+
...
|
|
330
|
+
|
|
331
|
+
def set_notice_receiver(
|
|
332
|
+
self, receiver: Callable[[Notice], Any] | None, /) -> None:
|
|
333
|
+
"""Set a custom notice receiver."""
|
|
334
|
+
...
|
|
335
|
+
|
|
336
|
+
def getnotify(self) -> tuple[str, int, str | bytes] | None:
|
|
337
|
+
"""Get the last notify from the server."""
|
|
338
|
+
...
|
|
339
|
+
|
|
340
|
+
def inserttable(self, table: str | bytes,
|
|
341
|
+
values: Iterable[list | tuple],
|
|
342
|
+
columns: _ColumnNames | None = None,
|
|
343
|
+
*, freeze: bool = False) -> int:
|
|
344
|
+
"""Insert a Python iterable into a database table."""
|
|
345
|
+
...
|
|
346
|
+
|
|
347
|
+
def transaction(self) -> int:
|
|
348
|
+
"""Get the current in-transaction status of the server.
|
|
349
|
+
|
|
350
|
+
The status returned by this method can be TRANS_IDLE (currently idle),
|
|
351
|
+
TRANS_ACTIVE (a command is in progress), TRANS_INTRANS (idle, in a
|
|
352
|
+
valid transaction block), or TRANS_INERROR (idle, in a failed
|
|
353
|
+
transaction block). TRANS_UNKNOWN is reported if the connection is
|
|
354
|
+
bad. The status TRANS_ACTIVE is reported only when a query has been
|
|
355
|
+
sent to the server and not yet completed.
|
|
356
|
+
"""
|
|
357
|
+
...
|
|
358
|
+
|
|
359
|
+
def parameter(self, name: str | bytes, /) -> str | None:
|
|
360
|
+
"""Look up a current parameter setting of the server."""
|
|
361
|
+
...
|
|
362
|
+
|
|
363
|
+
def date_format(self) -> str:
|
|
364
|
+
"""Look up the date format currently being used by the database."""
|
|
365
|
+
...
|
|
366
|
+
|
|
367
|
+
def escape_literal(self, s: _AnyStr, /) -> _AnyStr:
|
|
368
|
+
"""Escape a literal constant for use within SQL."""
|
|
369
|
+
...
|
|
370
|
+
|
|
371
|
+
def escape_identifier(self, s: _AnyStr, /) -> _AnyStr:
|
|
372
|
+
"""Escape an identifier for use within SQL."""
|
|
373
|
+
...
|
|
374
|
+
|
|
375
|
+
def escape_string(self, s: _AnyStr, /) -> _AnyStr:
|
|
376
|
+
"""Escape a string for use within SQL."""
|
|
377
|
+
...
|
|
378
|
+
|
|
379
|
+
def escape_bytea(self, s: _AnyStr, /) -> _AnyStr:
|
|
380
|
+
"""Escape binary data for use within SQL as type 'bytea'."""
|
|
381
|
+
...
|
|
382
|
+
|
|
383
|
+
def encrypt_password(self, password: str | bytes, user: str | bytes,
|
|
384
|
+
algorithm: str | bytes | None = None) -> str:
|
|
385
|
+
"""Encrypt a password."""
|
|
386
|
+
...
|
|
387
|
+
|
|
388
|
+
def change_password(self, user: str | bytes,
|
|
389
|
+
password: str | bytes) -> None:
|
|
390
|
+
"""Change the password of a user."""
|
|
391
|
+
...
|
|
392
|
+
|
|
393
|
+
def putline(self, line: str | bytes, /) -> None:
|
|
394
|
+
"""Write a line to the server socket."""
|
|
395
|
+
...
|
|
396
|
+
|
|
397
|
+
def getline(self) -> str | bytes | None:
|
|
398
|
+
"""Get a line from server socket."""
|
|
399
|
+
...
|
|
400
|
+
|
|
401
|
+
def endcopy(self) -> None:
|
|
402
|
+
"""Synchronize client and server."""
|
|
403
|
+
...
|
|
404
|
+
|
|
405
|
+
def set_non_blocking(self, nb: bool, /) -> None:
|
|
406
|
+
"""Set the non-blocking mode of the connection."""
|
|
407
|
+
...
|
|
408
|
+
|
|
409
|
+
def is_non_blocking(self) -> bool:
|
|
410
|
+
"""Get the non-blocking mode of the connection."""
|
|
411
|
+
...
|
|
412
|
+
|
|
413
|
+
def locreate(self, mode: int, /) -> LargeObject:
|
|
414
|
+
"""Create a large object in the database.
|
|
415
|
+
|
|
416
|
+
The valid values for 'mode' parameter are defined as the module level
|
|
417
|
+
constants INV_READ and INV_WRITE.
|
|
418
|
+
"""
|
|
419
|
+
...
|
|
420
|
+
|
|
421
|
+
def getlo(self, oid: int, /) -> LargeObject:
|
|
422
|
+
"""Build a large object from given oid."""
|
|
423
|
+
...
|
|
424
|
+
|
|
425
|
+
def loimport(self, filename: _StrOrBytesPath, /) -> LargeObject:
|
|
426
|
+
"""Import a file to a large object."""
|
|
427
|
+
...
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
@final
|
|
431
|
+
class Query:
|
|
432
|
+
"""Query object.
|
|
433
|
+
|
|
434
|
+
The Query object returned by Connection.query and DB.query can be used
|
|
435
|
+
as an iterable returning rows as tuples. You can also directly access
|
|
436
|
+
row tuples using their index, and get the number of rows with the
|
|
437
|
+
len() function. The Query class also provides the several methods
|
|
438
|
+
for accessing the results of the query.
|
|
439
|
+
"""
|
|
440
|
+
|
|
441
|
+
def __len__(self) -> int:
|
|
442
|
+
...
|
|
443
|
+
|
|
444
|
+
def __getitem__(self, key: int, /) -> tuple:
|
|
445
|
+
...
|
|
446
|
+
|
|
447
|
+
def __iter__(self) -> Query:
|
|
448
|
+
...
|
|
449
|
+
|
|
450
|
+
def __next__(self) -> tuple:
|
|
451
|
+
...
|
|
452
|
+
|
|
453
|
+
def getresult(self) -> list[tuple]:
|
|
454
|
+
"""Get query values as list of tuples."""
|
|
455
|
+
...
|
|
456
|
+
|
|
457
|
+
def dictresult(self) -> list[dict[str, object]]:
|
|
458
|
+
"""Get query values as list of dictionaries."""
|
|
459
|
+
...
|
|
460
|
+
|
|
461
|
+
def dictiter(self) -> Iterable[dict[str, object]]:
|
|
462
|
+
"""Get query values as iterable of dictionaries."""
|
|
463
|
+
...
|
|
464
|
+
|
|
465
|
+
def namedresult(self) -> list[_SomeNamedTuple]:
|
|
466
|
+
"""Get query values as list of named tuples."""
|
|
467
|
+
...
|
|
468
|
+
|
|
469
|
+
def namediter(self) -> Iterable[_SomeNamedTuple]:
|
|
470
|
+
"""Get query values as iterable of named tuples."""
|
|
471
|
+
...
|
|
472
|
+
|
|
473
|
+
def one(self) -> tuple | None:
|
|
474
|
+
"""Get one row from the result of a query as a tuple."""
|
|
475
|
+
...
|
|
476
|
+
|
|
477
|
+
def single(self) -> tuple:
|
|
478
|
+
"""Get single row from the result of a query as a tuple."""
|
|
479
|
+
...
|
|
480
|
+
|
|
481
|
+
def onedict(self) -> dict[str, object] | None:
|
|
482
|
+
"""Get one row from the result of a query as a dictionary."""
|
|
483
|
+
...
|
|
484
|
+
|
|
485
|
+
def singledict(self) -> dict[str, object]:
|
|
486
|
+
"""Get single row from the result of a query as a dictionary."""
|
|
487
|
+
...
|
|
488
|
+
|
|
489
|
+
def onenamed(self) -> _SomeNamedTuple | None:
|
|
490
|
+
"""Get one row from the result of a query as named tuple."""
|
|
491
|
+
...
|
|
492
|
+
|
|
493
|
+
def singlenamed(self) -> _SomeNamedTuple:
|
|
494
|
+
"""Get single row from the result of a query as named tuple."""
|
|
495
|
+
...
|
|
496
|
+
|
|
497
|
+
def scalarresult(self) -> list:
|
|
498
|
+
"""Get first fields from query result as list of scalar values."""
|
|
499
|
+
...
|
|
500
|
+
|
|
501
|
+
def scalariter(self) -> Iterable:
|
|
502
|
+
"""Get first fields from query result as iterable of scalar values."""
|
|
503
|
+
...
|
|
504
|
+
|
|
505
|
+
def onescalar(self) -> object | None:
|
|
506
|
+
"""Get one row from the result of a query as scalar value."""
|
|
507
|
+
...
|
|
508
|
+
|
|
509
|
+
def singlescalar(self) -> object:
|
|
510
|
+
"""Get single row from the result of a query as scalar value."""
|
|
511
|
+
...
|
|
512
|
+
|
|
513
|
+
def fieldname(self, num: int, /) -> str:
|
|
514
|
+
"""Get field name from its number."""
|
|
515
|
+
...
|
|
516
|
+
|
|
517
|
+
def fieldnum(self, name: str | bytes, /) -> int:
|
|
518
|
+
"""Get field number from its name."""
|
|
519
|
+
...
|
|
520
|
+
|
|
521
|
+
def listfields(self) -> tuple[str, ...]:
|
|
522
|
+
"""List field names of query result."""
|
|
523
|
+
...
|
|
524
|
+
|
|
525
|
+
@overload
|
|
526
|
+
def fieldinfo(self, /) -> tuple[tuple[str, int, int, int], ...]:
|
|
527
|
+
"""Get information on all fields of the query.
|
|
528
|
+
|
|
529
|
+
The four-tuples contain the following information:
|
|
530
|
+
The field name, the internal OID number of the field type,
|
|
531
|
+
the size in bytes of the column or a negative value if it is
|
|
532
|
+
of variable size, and a type-specific modifier value.
|
|
533
|
+
"""
|
|
534
|
+
...
|
|
535
|
+
|
|
536
|
+
@overload
|
|
537
|
+
def fieldinfo(self, column: int | str | bytes, /
|
|
538
|
+
) -> tuple[str, int, int, int]:
|
|
539
|
+
"""Get information on one field of the query.
|
|
540
|
+
|
|
541
|
+
The four-tuple contains the following information:
|
|
542
|
+
The field name, the internal OID number of the field type,
|
|
543
|
+
the size in bytes of the column or a negative value if it is
|
|
544
|
+
of variable size, and a type-specific modifier value.
|
|
545
|
+
"""
|
|
546
|
+
...
|
|
547
|
+
|
|
548
|
+
def memsize(self) -> int:
|
|
549
|
+
"""Return number of bytes allocated by query result."""
|
|
550
|
+
...
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def connect(dbname: str | bytes | None = None,
|
|
554
|
+
host: str | bytes | None = None,
|
|
555
|
+
port: int | None = None,
|
|
556
|
+
opt: str | bytes | None = None,
|
|
557
|
+
user: str | bytes | None = None,
|
|
558
|
+
passwd: str | bytes | None = None,
|
|
559
|
+
nowait: bool = False) -> Connection:
|
|
560
|
+
"""Connect to a PostgreSQL database."""
|
|
561
|
+
...
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def cast_array(string: str | bytes, cast: Callable | None = None,
|
|
565
|
+
delim: bytes = b',') -> list:
|
|
566
|
+
"""Cast a string representing a PostgreSQL array to a Python list."""
|
|
567
|
+
...
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
def cast_record(string: str | bytes,
|
|
571
|
+
cast: Callable | list[Callable | None] |
|
|
572
|
+
tuple[Callable | None, ...] | None = None,
|
|
573
|
+
delim: bytes = b',') -> tuple:
|
|
574
|
+
"""Cast a string representing a PostgreSQL record to a Python tuple."""
|
|
575
|
+
...
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
@overload
|
|
579
|
+
def cast_hstore(string: str, /) -> dict[str, str | None]:
|
|
580
|
+
"""Cast a string as an hstore."""
|
|
581
|
+
...
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
@overload
|
|
585
|
+
def cast_hstore(string: bytes, /
|
|
586
|
+
) -> dict[str | bytes, str | bytes | None]:
|
|
587
|
+
"""Cast bytes as an hstore (non-ASCII text is returned as bytes)."""
|
|
588
|
+
...
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
def escape_bytea(s: _AnyStr, /) -> _AnyStr:
|
|
592
|
+
"""Escape binary data for use within SQL as type 'bytea'."""
|
|
593
|
+
...
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def unescape_bytea(s: _AnyStr, /) -> bytes:
|
|
597
|
+
"""Unescape 'bytea' data that has been retrieved as text."""
|
|
598
|
+
...
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
def escape_string(s: _AnyStr, /) -> _AnyStr:
|
|
602
|
+
"""Escape a string for use within SQL."""
|
|
603
|
+
...
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def get_pqlib_version() -> int:
|
|
607
|
+
"""Get the version of libpq that is being used by PyGreSQL."""
|
|
608
|
+
...
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
def get_array() -> bool:
|
|
612
|
+
"""Check whether arrays are returned as list objects."""
|
|
613
|
+
...
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def set_array(on: bool | int, /) -> None:
|
|
617
|
+
"""Set whether arrays are returned as list objects."""
|
|
618
|
+
...
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
def get_bool() -> bool:
|
|
622
|
+
"""Check whether boolean values are returned as bool objects."""
|
|
623
|
+
...
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def set_bool(on: bool | int, /) -> None:
|
|
627
|
+
"""Set whether boolean values are returned as bool objects."""
|
|
628
|
+
...
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
def get_bytea_escaped() -> bool:
|
|
632
|
+
"""Check whether 'bytea' values are returned as escaped strings."""
|
|
633
|
+
...
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
def set_bytea_escaped(on: bool | int, /) -> None:
|
|
637
|
+
"""Set whether 'bytea' values are returned as escaped strings."""
|
|
638
|
+
...
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
def get_datestyle() -> str | None:
|
|
642
|
+
"""Get the assumed date style for typecasting."""
|
|
643
|
+
...
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
def set_datestyle(datestyle: str | None, /) -> None:
|
|
647
|
+
"""Set a fixed date style that shall be assumed when typecasting."""
|
|
648
|
+
...
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
def get_decimal() -> type | None:
|
|
652
|
+
"""Get the decimal type to be used for numeric values."""
|
|
653
|
+
...
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
def set_decimal(cls: type | None, /) -> None:
|
|
657
|
+
"""Set a decimal type to be used for numeric values."""
|
|
658
|
+
...
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def get_decimal_point() -> str | None:
|
|
662
|
+
"""Get the decimal mark used for monetary values."""
|
|
663
|
+
...
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
def set_decimal_point(mark: str | None, /) -> None:
|
|
667
|
+
"""Specify which decimal mark is used for interpreting monetary values."""
|
|
668
|
+
...
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def get_jsondecode() -> Callable[[str | bytes], object] | None:
|
|
672
|
+
"""Get the function that deserializes JSON formatted strings."""
|
|
673
|
+
...
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
def set_jsondecode(decode: Callable[[str | bytes], object] | None, /
|
|
677
|
+
) -> None:
|
|
678
|
+
"""Set a function that will deserialize JSON formatted strings."""
|
|
679
|
+
...
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def get_defbase() -> str | bytes | None:
|
|
683
|
+
"""Get the default database name."""
|
|
684
|
+
...
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
def set_defbase(base: str | bytes | None, /) -> str | bytes | None:
|
|
688
|
+
"""Set the default database name and return the previous value."""
|
|
689
|
+
...
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
def get_defhost() -> str | bytes | None:
|
|
693
|
+
"""Get the default host."""
|
|
694
|
+
...
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
def set_defhost(host: str | bytes | None, /) -> str | bytes | None:
|
|
698
|
+
"""Set the default host and return the previous value."""
|
|
699
|
+
...
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
def get_defport() -> int | None:
|
|
703
|
+
"""Get the default port."""
|
|
704
|
+
...
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
def set_defport(port: int | None, /) -> int | None:
|
|
708
|
+
"""Set the default port and return the previous value."""
|
|
709
|
+
...
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
def get_defopt() -> str | bytes | None:
|
|
713
|
+
"""Get the default connection options."""
|
|
714
|
+
...
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
def set_defopt(opt: str | bytes | None, /) -> str | bytes | None:
|
|
718
|
+
"""Set the default connection options and return the previous value."""
|
|
719
|
+
...
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
def get_defuser() -> str | bytes | None:
|
|
723
|
+
"""Get the default database user."""
|
|
724
|
+
...
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
def set_defuser(user: str | bytes | None, /) -> str | bytes | None:
|
|
728
|
+
"""Set the default database user and return the previous value."""
|
|
729
|
+
...
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
def set_defpasswd(passwd: str | bytes | None, /) -> None:
|
|
733
|
+
"""Set the default database password."""
|
|
734
|
+
...
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
def set_query_helpers(*helpers: Callable) -> None:
|
|
738
|
+
"""Set internal query helper functions."""
|
|
739
|
+
...
|