PyGreSQL 6.2.0__tar.gz → 6.2.1__tar.gz
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.
- {pygresql-6.2.0 → pygresql-6.2.1}/PKG-INFO +1 -1
- {pygresql-6.2.0 → pygresql-6.2.1}/PyGreSQL.egg-info/PKG-INFO +1 -1
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/changelog.rst +7 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/connection.rst +2 -1
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pgconn.c +18 -8
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/_pg.pyi +2 -1
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/db.py +5 -3
- {pygresql-6.2.0 → pygresql-6.2.1}/pyproject.toml +1 -1
- {pygresql-6.2.0 → pygresql-6.2.1}/setup.py +34 -23
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic_connection.py +22 -1
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic_dbwrapper.py +18 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/LICENSE.txt +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/MANIFEST.in +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/PyGreSQL.egg-info/SOURCES.txt +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/PyGreSQL.egg-info/dependency_links.txt +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/PyGreSQL.egg-info/not-zip-safe +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/PyGreSQL.egg-info/top_level.txt +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/README.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/Makefile +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/_static/favicon.ico +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/_static/pygresql.png +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/about.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/community/homes.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/community/index.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/community/issues.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/community/mailinglist.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/community/source.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/community/support.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/conf.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/examples.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/general.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/index.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/install.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/adaptation.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/db_types.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/db_wrapper.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/index.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/introduction.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/large_objects.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/module.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/notification.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pg/query.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/adaptation.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/connection.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/cursor.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/index.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/introduction.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/module.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/typecache.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/pgdb/types.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/postgres/advanced.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/postgres/basic.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/postgres/func.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/postgres/index.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/postgres/syscat.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/contents/tutorial.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/copyright.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/download/download.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/download/files.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/download/index.rst +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/make.bat +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/docs/requirements.txt +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pginternal.c +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pglarge.c +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pgmodule.c +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pgnotice.c +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pgquery.c +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pgsource.c +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/ext/pgtypes.h +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/__init__.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/adapt.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/attrs.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/cast.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/core.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/error.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/helpers.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/notify.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/py.typed +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pg/tz.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/__init__.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/adapt.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/cast.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/connect.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/connection.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/constants.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/cursor.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/py.typed +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/pgdb/typecode.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/setup.cfg +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/__init__.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/config.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/dbapi20.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic_attrdict.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic_functions.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic_largeobj.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_classic_notification.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_dbapi20.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_dbapi20_copy.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tests/test_tutorial.py +0 -0
- {pygresql-6.2.0 → pygresql-6.2.1}/tox.ini +0 -0
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
ChangeLog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
Version 6.2.1 (2025-12-27)
|
|
5
|
+
--------------------------
|
|
6
|
+
- Made setup cleaner and work with a wider range of setuptools versions (#90).
|
|
7
|
+
- The `inserttable()` method in the `pg` module now supports an optional
|
|
8
|
+
`freeze` parameter to optimize initial bulk loading (#81).
|
|
9
|
+
|
|
4
10
|
Version 6.2.0 (2025-12-21)
|
|
5
11
|
--------------------------
|
|
6
12
|
- Added support for Python 3.14 and PostgreSQL 18.
|
|
7
13
|
- Removed support for Python versions older than 3.8 (released October 2019)
|
|
8
14
|
and PostgreSQL older than version 12 (released October 2019).
|
|
15
|
+
- Fixed `set_parameter()` for values containing special characters.
|
|
9
16
|
|
|
10
17
|
Version 6.1.0 (2024-12-05)
|
|
11
18
|
--------------------------
|
|
@@ -478,13 +478,14 @@ first, otherwise :meth:`Connection.getnotify` will always return ``None``.
|
|
|
478
478
|
inserttable -- insert an iterable into a table
|
|
479
479
|
----------------------------------------------
|
|
480
480
|
|
|
481
|
-
.. method:: Connection.inserttable(table, values, [columns])
|
|
481
|
+
.. method:: Connection.inserttable(table, values, [columns], *, freeze=False)
|
|
482
482
|
|
|
483
483
|
Insert a Python iterable into a database table
|
|
484
484
|
|
|
485
485
|
:param str table: the table name
|
|
486
486
|
:param list values: iterable of row values, which must be lists or tuples
|
|
487
487
|
:param list columns: list or tuple of column names
|
|
488
|
+
:param bool freeze: if True, immediately freeze the inserted rows
|
|
488
489
|
:rtype: int
|
|
489
490
|
:raises TypeError: invalid connection, bad argument type, or too many arguments
|
|
490
491
|
:raises MemoryError: insert buffer could not be allocated
|
|
@@ -708,28 +708,34 @@ conn_is_non_blocking(connObject *self, PyObject *noargs)
|
|
|
708
708
|
static char conn_inserttable__doc__[] =
|
|
709
709
|
"inserttable(table, data, [columns]) -- insert iterable into table\n\n"
|
|
710
710
|
"The fields in the iterable must be in the same order as in the table\n"
|
|
711
|
-
"or in the list or tuple of columns if one is specified.\n"
|
|
711
|
+
"or in the list or tuple of columns if one is specified.\n\n"
|
|
712
|
+
"If the optional argument 'freeze' is set to True, the inserted rows\n"
|
|
713
|
+
"will be immediately frozen (can be useful for initial bulk loads).\n";
|
|
712
714
|
|
|
713
715
|
static PyObject *
|
|
714
|
-
conn_inserttable(connObject *self, PyObject *args)
|
|
716
|
+
conn_inserttable(connObject *self, PyObject *args, PyObject *kwds)
|
|
715
717
|
{
|
|
716
718
|
PGresult *result;
|
|
717
719
|
char *table, *buffer, *bufpt, *bufmax, *s, *t;
|
|
718
|
-
int encoding, ret;
|
|
720
|
+
int freeze = 0, encoding, ret;
|
|
719
721
|
size_t bufsiz;
|
|
720
722
|
PyObject *rows, *iter_row, *item, *columns = NULL;
|
|
721
723
|
Py_ssize_t i, j, m, n;
|
|
722
724
|
|
|
725
|
+
static char *kwlist[] = {"table", "data", "columns", "freeze", NULL};
|
|
726
|
+
|
|
723
727
|
if (!self->cnx) {
|
|
724
728
|
PyErr_SetString(PyExc_TypeError, "Connection is not valid");
|
|
725
729
|
return NULL;
|
|
726
730
|
}
|
|
727
731
|
|
|
728
732
|
/* gets arguments */
|
|
729
|
-
if (!
|
|
733
|
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO|O$p", kwlist, &table,
|
|
734
|
+
&rows, &columns, &freeze)) {
|
|
730
735
|
PyErr_SetString(
|
|
731
736
|
PyExc_TypeError,
|
|
732
|
-
"Method inserttable() expects a string
|
|
737
|
+
"Method inserttable() expects a string, an iterable, an optional "
|
|
738
|
+
"list/tuple and an optional boolean 'freeze' as arguments");
|
|
733
739
|
return NULL;
|
|
734
740
|
}
|
|
735
741
|
|
|
@@ -834,7 +840,11 @@ conn_inserttable(connObject *self, PyObject *args)
|
|
|
834
840
|
}
|
|
835
841
|
}
|
|
836
842
|
if (bufpt < bufmax)
|
|
837
|
-
snprintf(bufpt, (size_t)(bufmax - bufpt), " from stdin");
|
|
843
|
+
bufpt += snprintf(bufpt, (size_t)(bufmax - bufpt), " from stdin");
|
|
844
|
+
if (freeze && bufpt < bufmax) {
|
|
845
|
+
bufpt += snprintf(bufpt, (size_t)(bufmax - bufpt), " freeze");
|
|
846
|
+
}
|
|
847
|
+
|
|
838
848
|
if (bufpt >= bufmax) {
|
|
839
849
|
PyMem_Free(buffer);
|
|
840
850
|
Py_DECREF(iter_row);
|
|
@@ -1753,8 +1763,8 @@ static struct PyMethodDef conn_methods[] = {
|
|
|
1753
1763
|
conn_set_notice_receiver__doc__},
|
|
1754
1764
|
{"getnotify", (PyCFunction)conn_get_notify, METH_NOARGS,
|
|
1755
1765
|
conn_get_notify__doc__},
|
|
1756
|
-
{"inserttable", (PyCFunction)conn_inserttable,
|
|
1757
|
-
conn_inserttable__doc__},
|
|
1766
|
+
{"inserttable", (PyCFunction)conn_inserttable,
|
|
1767
|
+
METH_VARARGS | METH_KEYWORDS, conn_inserttable__doc__},
|
|
1758
1768
|
{"transaction", (PyCFunction)conn_transaction, METH_NOARGS,
|
|
1759
1769
|
conn_transaction__doc__},
|
|
1760
1770
|
{"parameter", (PyCFunction)conn_parameter, METH_VARARGS,
|
|
@@ -268,7 +268,8 @@ class Connection:
|
|
|
268
268
|
...
|
|
269
269
|
|
|
270
270
|
def inserttable(self, table: str, values: Sequence[list|tuple],
|
|
271
|
-
columns: list[str] | tuple[str, ...] | None = None
|
|
271
|
+
columns: list[str] | tuple[str, ...] | None = None,
|
|
272
|
+
freeze: bool=False) -> int:
|
|
272
273
|
"""Insert a Python iterable into a database table."""
|
|
273
274
|
...
|
|
274
275
|
|
|
@@ -1403,11 +1403,13 @@ class DB:
|
|
|
1403
1403
|
return self._valid_db.getnotify()
|
|
1404
1404
|
|
|
1405
1405
|
def inserttable(self, table: str, values: Sequence[list|tuple],
|
|
1406
|
-
columns: list[str] | tuple[str, ...] | None = None
|
|
1406
|
+
columns: list[str] | tuple[str, ...] | None = None,
|
|
1407
|
+
freeze: bool=False) -> int:
|
|
1407
1408
|
"""Insert a Python iterable into a database table."""
|
|
1408
1409
|
if columns is None:
|
|
1409
|
-
return self._valid_db.inserttable(table, values)
|
|
1410
|
-
return self._valid_db.inserttable(
|
|
1410
|
+
return self._valid_db.inserttable(table, values, freeze=freeze)
|
|
1411
|
+
return self._valid_db.inserttable(
|
|
1412
|
+
table, values, columns, freeze=freeze)
|
|
1411
1413
|
|
|
1412
1414
|
def transaction(self) -> int:
|
|
1413
1415
|
"""Get the current in-transaction status of the server.
|
|
@@ -13,13 +13,16 @@ import os
|
|
|
13
13
|
import platform
|
|
14
14
|
import re
|
|
15
15
|
import sys
|
|
16
|
+
import sysconfig
|
|
16
17
|
import warnings
|
|
17
18
|
|
|
18
19
|
from setuptools import Extension, setup
|
|
19
|
-
from setuptools._distutils.ccompiler import get_default_compiler
|
|
20
|
-
from setuptools._distutils.sysconfig import get_python_inc, get_python_lib
|
|
21
20
|
from setuptools.command.build_ext import build_ext
|
|
22
21
|
|
|
22
|
+
min_py_version = 3, 8 # supported: Python >= 3.8
|
|
23
|
+
max_py_version = 4, 0 # and < 4.0
|
|
24
|
+
min_pg_version = 12, 0 # supported: PostgreSQL >= 12.0
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
def project_version():
|
|
25
28
|
"""Read the PyGreSQL version from the pyproject.toml file."""
|
|
@@ -39,7 +42,7 @@ def project_readme():
|
|
|
39
42
|
|
|
40
43
|
version = project_version()
|
|
41
44
|
|
|
42
|
-
if not
|
|
45
|
+
if not min_py_version <= sys.version_info[:2] < max_py_version:
|
|
43
46
|
raise Exception(
|
|
44
47
|
f"Sorry, PyGreSQL {version} does not support this Python version")
|
|
45
48
|
|
|
@@ -54,12 +57,15 @@ def patch_pyproject_toml():
|
|
|
54
57
|
|
|
55
58
|
try:
|
|
56
59
|
version = int(version.split('.', 1)[0])
|
|
57
|
-
except
|
|
60
|
+
except (IndexError, TypeError, ValueError):
|
|
58
61
|
return
|
|
59
|
-
if version
|
|
62
|
+
if not 61 <= version < 77: # only needed for setuptools 61 to 76
|
|
60
63
|
return
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
try:
|
|
66
|
+
from setuptools.config import pyprojecttoml
|
|
67
|
+
except ImportError:
|
|
68
|
+
return
|
|
63
69
|
|
|
64
70
|
load_file = pyprojecttoml.load_file
|
|
65
71
|
|
|
@@ -99,21 +105,21 @@ def pg_version():
|
|
|
99
105
|
match = re.search(r'(\d+)\.(\d+)', pg_config('version'))
|
|
100
106
|
if match:
|
|
101
107
|
return tuple(map(int, match.groups()))
|
|
102
|
-
return
|
|
108
|
+
return min_pg_version
|
|
103
109
|
|
|
104
110
|
|
|
105
111
|
pg_version = pg_version()
|
|
106
112
|
libraries = ['pq']
|
|
107
113
|
# Make sure that the Python header files are searched before
|
|
108
114
|
# those of PostgreSQL, because PostgreSQL can have its own Python.h
|
|
109
|
-
include_dirs = [
|
|
110
|
-
library_dirs = [
|
|
115
|
+
include_dirs = [sysconfig.get_path("include"), pg_config('includedir')]
|
|
116
|
+
library_dirs = [sysconfig.get_path("purelib"), pg_config('libdir')]
|
|
111
117
|
define_macros = [('PYGRESQL_VERSION', version)]
|
|
112
118
|
undef_macros = []
|
|
113
119
|
extra_compile_args = ['-O2', '-funsigned-char', '-Wall', '-Wconversion']
|
|
114
120
|
|
|
115
121
|
|
|
116
|
-
class
|
|
122
|
+
class BuildPgExt(build_ext):
|
|
117
123
|
"""Customized build_ext command for PyGreSQL."""
|
|
118
124
|
|
|
119
125
|
description = "build the PyGreSQL C extension"
|
|
@@ -129,28 +135,28 @@ class build_pg_ext(build_ext): # noqa: N801
|
|
|
129
135
|
negative_opt = { # noqa: RUF012
|
|
130
136
|
'no-memory-size': 'memory-size'}
|
|
131
137
|
|
|
132
|
-
def get_compiler(self):
|
|
133
|
-
"""Return the C compiler used for building the extension."""
|
|
134
|
-
return self.compiler or get_default_compiler()
|
|
135
|
-
|
|
136
138
|
def initialize_options(self):
|
|
137
139
|
"""Initialize the supported options with default values."""
|
|
138
|
-
|
|
140
|
+
super().initialize_options()
|
|
139
141
|
self.strict = False
|
|
140
142
|
self.memory_size = None
|
|
141
|
-
supported = pg_version >=
|
|
143
|
+
supported = pg_version >= min_pg_version
|
|
142
144
|
if not supported:
|
|
143
145
|
warnings.warn(
|
|
144
146
|
"PyGreSQL does not support the installed PostgreSQL version.",
|
|
145
147
|
stacklevel=2)
|
|
146
148
|
|
|
147
149
|
def finalize_options(self):
|
|
148
|
-
"""Set
|
|
149
|
-
|
|
150
|
+
"""Set values for all build_pg options.
|
|
151
|
+
|
|
152
|
+
Some values are set in build_extensions() since they depend
|
|
153
|
+
on the compiler version which is not yet known at this point.
|
|
154
|
+
"""
|
|
155
|
+
super().finalize_options()
|
|
150
156
|
if self.strict:
|
|
151
157
|
extra_compile_args.append('-Werror')
|
|
152
158
|
wanted = self.memory_size
|
|
153
|
-
supported = pg_version >=
|
|
159
|
+
supported = pg_version >= min_pg_version
|
|
154
160
|
if (wanted is None and supported) or wanted:
|
|
155
161
|
define_macros.append(('MEMORY_SIZE', None))
|
|
156
162
|
if not supported:
|
|
@@ -158,19 +164,24 @@ class build_pg_ext(build_ext): # noqa: N801
|
|
|
158
164
|
"The installed PostgreSQL version"
|
|
159
165
|
" does not support the memory size function.",
|
|
160
166
|
stacklevel=2)
|
|
167
|
+
|
|
168
|
+
def build_extensions(self):
|
|
169
|
+
"""Build the PyGreSQL C extension."""
|
|
170
|
+
# Adjust settings for Windows platforms
|
|
161
171
|
if sys.platform == 'win32':
|
|
162
172
|
libraries[0] = 'lib' + libraries[0]
|
|
163
173
|
if os.path.exists(os.path.join(
|
|
164
174
|
library_dirs[1], libraries[0] + 'dll.lib')):
|
|
165
175
|
libraries[0] += 'dll'
|
|
166
|
-
|
|
167
|
-
if
|
|
176
|
+
compiler_type = self.compiler.compiler_type
|
|
177
|
+
if compiler_type == 'mingw32': # MinGW
|
|
168
178
|
if platform.architecture()[0] == '64bit': # needs MinGW-w64
|
|
169
179
|
define_macros.append(('MS_WIN64', None))
|
|
170
|
-
elif
|
|
180
|
+
elif compiler_type == 'msvc': # Microsoft Visual C++
|
|
171
181
|
extra_compile_args[1:] = [
|
|
172
182
|
'-J', '-W3', '-WX', '-wd4391',
|
|
173
183
|
'-Dinline=__inline'] # needed for MSVC 9
|
|
184
|
+
super().build_extensions()
|
|
174
185
|
|
|
175
186
|
|
|
176
187
|
setup(
|
|
@@ -217,5 +228,5 @@ setup(
|
|
|
217
228
|
include_dirs=include_dirs, library_dirs=library_dirs,
|
|
218
229
|
define_macros=define_macros, undef_macros=undef_macros,
|
|
219
230
|
libraries=libraries, extra_compile_args=extra_compile_args)],
|
|
220
|
-
cmdclass=dict(build_ext=
|
|
231
|
+
cmdclass=dict(build_ext=BuildPgExt),
|
|
221
232
|
)
|
|
@@ -2118,7 +2118,28 @@ class TestInserttable(unittest.TestCase):
|
|
|
2118
2118
|
self.assertIn(
|
|
2119
2119
|
'value "33000" is out of range for type smallint', str(e))
|
|
2120
2120
|
else:
|
|
2121
|
-
self.assertFalse('expected an error')
|
|
2121
|
+
self.assertFalse('expected an error since value is out of range')
|
|
2122
|
+
|
|
2123
|
+
def test_insert_table_with_freeze_false(self):
|
|
2124
|
+
data = self.data
|
|
2125
|
+
self.c.inserttable('test', data, freeze=False)
|
|
2126
|
+
self.assertEqual(self.get_back(), data)
|
|
2127
|
+
|
|
2128
|
+
def test_insert_table_with_freeze_true_without_truncate(self):
|
|
2129
|
+
try:
|
|
2130
|
+
self.c.inserttable('test', self.data, freeze=True)
|
|
2131
|
+
except ValueError as e:
|
|
2132
|
+
self.assertIn('cannot perform COPY FREEZE', str(e))
|
|
2133
|
+
else:
|
|
2134
|
+
self.assertFalse('expected an error since table was not truncated')
|
|
2135
|
+
|
|
2136
|
+
def test_insert_table_with_freeze_true_with_truncate(self):
|
|
2137
|
+
data = self.data
|
|
2138
|
+
self.c.query("begin")
|
|
2139
|
+
self.c.query('truncate table test')
|
|
2140
|
+
self.c.inserttable('test', data, freeze=True)
|
|
2141
|
+
self.c.query('commit')
|
|
2142
|
+
self.assertEqual(self.get_back(), data)
|
|
2122
2143
|
|
|
2123
2144
|
|
|
2124
2145
|
class TestDirectSocketAccess(unittest.TestCase):
|
|
@@ -4233,6 +4233,24 @@ class TestDBClass(unittest.TestCase):
|
|
|
4233
4233
|
self.assertEqual([row[0] for row in data_from], [1, 2, 3])
|
|
4234
4234
|
self.assertEqual(data_from, data_to)
|
|
4235
4235
|
|
|
4236
|
+
def test_inserttable_with_freeze(self):
|
|
4237
|
+
# use inserttable() with freeze and table created in same transaction
|
|
4238
|
+
query = self.db.query
|
|
4239
|
+
values = [(i,) for i in range(1, 4)]
|
|
4240
|
+
self.db.begin()
|
|
4241
|
+
self.create_table('test_table_freeze', 'n integer')
|
|
4242
|
+
self.db.inserttable('test_table_freeze', values, freeze=True)
|
|
4243
|
+
self.db.commit()
|
|
4244
|
+
r = query("select * from test_table_freeze").getresult()
|
|
4245
|
+
self.assertEqual(r, values)
|
|
4246
|
+
|
|
4247
|
+
def test_inserttable_with_freeze_no_transaction(self):
|
|
4248
|
+
# use inserttable() with freeze and table created before transaction
|
|
4249
|
+
values = [(i,) for i in range(1, 4)]
|
|
4250
|
+
self.create_table('test_table_freeze', 'n integer')
|
|
4251
|
+
self.assertRaises(ValueError, self.db.inserttable,
|
|
4252
|
+
'test_table_freeze', values, freeze=True)
|
|
4253
|
+
|
|
4236
4254
|
|
|
4237
4255
|
class TestDBClassNonStdOpts(TestDBClass):
|
|
4238
4256
|
"""Test the methods of the DB class with non-standard global options."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|