pyodbc 5.2.0__tar.gz → 5.3.0__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.
Files changed (45) hide show
  1. pyodbc-5.3.0/PKG-INFO +58 -0
  2. {pyodbc-5.2.0 → pyodbc-5.3.0}/pyproject.toml +3 -4
  3. {pyodbc-5.2.0 → pyodbc-5.3.0}/setup.py +7 -2
  4. pyodbc-5.3.0/src/pyodbc.egg-info/PKG-INFO +58 -0
  5. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbc.egg-info/SOURCES.txt +1 -0
  6. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbcmodule.cpp +1 -2
  7. {pyodbc-5.2.0 → pyodbc-5.3.0}/tests/conftest.py +2 -2
  8. pyodbc-5.3.0/tests/sqlite_test.py +638 -0
  9. pyodbc-5.2.0/PKG-INFO +0 -25
  10. pyodbc-5.2.0/src/pyodbc.egg-info/PKG-INFO +0 -25
  11. {pyodbc-5.2.0 → pyodbc-5.3.0}/LICENSE.txt +0 -0
  12. {pyodbc-5.2.0 → pyodbc-5.3.0}/MANIFEST.in +0 -0
  13. {pyodbc-5.2.0 → pyodbc-5.3.0}/README.md +0 -0
  14. {pyodbc-5.2.0 → pyodbc-5.3.0}/setup.cfg +0 -0
  15. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/cnxninfo.cpp +0 -0
  16. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/cnxninfo.h +0 -0
  17. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/connection.cpp +0 -0
  18. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/connection.h +0 -0
  19. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/cursor.cpp +0 -0
  20. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/cursor.h +0 -0
  21. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/dbspecific.h +0 -0
  22. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/decimal.cpp +0 -0
  23. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/decimal.h +0 -0
  24. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/errors.cpp +0 -0
  25. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/errors.h +0 -0
  26. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/getdata.cpp +0 -0
  27. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/getdata.h +0 -0
  28. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/params.cpp +0 -0
  29. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/params.h +0 -0
  30. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbc.egg-info/dependency_links.txt +0 -0
  31. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbc.egg-info/top_level.txt +0 -0
  32. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbc.h +0 -0
  33. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbc.pyi +0 -0
  34. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbcdbg.cpp +0 -0
  35. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/pyodbcmodule.h +0 -0
  36. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/resource.h +0 -0
  37. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/row.cpp +0 -0
  38. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/row.h +0 -0
  39. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/textenc.cpp +0 -0
  40. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/textenc.h +0 -0
  41. {pyodbc-5.2.0 → pyodbc-5.3.0}/src/wrapper.h +0 -0
  42. {pyodbc-5.2.0 → pyodbc-5.3.0}/tests/__init__.py +0 -0
  43. {pyodbc-5.2.0 → pyodbc-5.3.0}/tests/mysql_test.py +0 -0
  44. {pyodbc-5.2.0 → pyodbc-5.3.0}/tests/postgresql_test.py +0 -0
  45. {pyodbc-5.2.0 → pyodbc-5.3.0}/tests/sqlserver_test.py +0 -0
pyodbc-5.3.0/PKG-INFO ADDED
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyodbc
3
+ Version: 5.3.0
4
+ Summary: DB API module for ODBC
5
+ Home-page: https://github.com/mkleehammer/pyodbc
6
+ Author-email: Michael Kleehammer <michael@kleehammer.com>
7
+ Maintainer: Michael Kleehammer
8
+ Maintainer-email: Michael Kleehammer <michael@kleehammer.com>
9
+ License: MIT
10
+ Project-URL: Homepage, https://github.com/mkleehammer/pyodbc
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Database
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE.txt
22
+ Dynamic: home-page
23
+ Dynamic: license-file
24
+ Dynamic: maintainer
25
+ Dynamic: requires-python
26
+
27
+ # pyodbc
28
+
29
+ [![Windows build](https://ci.appveyor.com/api/projects/status/github/mkleehammer/pyodbc?branch=master&svg=true&passingText=Windows%20build&failingText=Windows%20build)](https://ci.appveyor.com/project/mkleehammer/pyodbc)
30
+ [![Ubuntu build](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml/badge.svg)](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml)
31
+ [![PyPI](https://img.shields.io/pypi/v/pyodbc?color=brightgreen)](https://pypi.org/project/pyodbc/)
32
+
33
+ pyodbc is an open source Python module that makes accessing ODBC databases simple. It
34
+ implements the [DB API 2.0](https://www.python.org/dev/peps/pep-0249) specification but is packed with even more Pythonic convenience.
35
+
36
+ The easiest way to install pyodbc is to use pip:
37
+
38
+ python -m pip install pyodbc
39
+
40
+ On Macs, you should probably install unixODBC first if you don't already have an ODBC
41
+ driver manager installed. For example, using the [homebrew](https://brew.sh/) package manager:
42
+
43
+ brew install unixodbc
44
+ python -m pip install pyodbc
45
+
46
+ Similarly, on Unix you should make sure you have an ODBC driver manager installed before
47
+ installing pyodbc. See the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install)
48
+ for more information about how to do this on different Unix flavors. (On Windows, the
49
+ ODBC driver manager is built-in.)
50
+
51
+ Precompiled binary wheels are provided for multiple Python versions on most Windows, macOS,
52
+ and Linux platforms. On other platforms pyodbc will be built from the source code. Note,
53
+ pyodbc contains C++ extensions so you will need a suitable C++ compiler when building from
54
+ source. See the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install) for details.
55
+
56
+ [Documentation](https://github.com/mkleehammer/pyodbc/wiki)
57
+
58
+ [Release Notes](https://github.com/mkleehammer/pyodbc/releases)
@@ -1,8 +1,8 @@
1
1
  [project]
2
2
  name = "pyodbc"
3
- version = "5.2.0"
3
+ version = "5.3.0"
4
4
 
5
- requires-python = ">=3.8"
5
+ requires-python = ">=3.9"
6
6
  # This is used by the GitHub action that builds release artifacts using cibuildwheel.
7
7
  # cibuildwheel reads this directly:
8
8
  #
@@ -10,7 +10,7 @@ requires-python = ">=3.8"
10
10
 
11
11
  description = "DB API module for ODBC"
12
12
  readme = "README.md"
13
- license = {text = "MIT-0 License"}
13
+ license = { text = "MIT" }
14
14
 
15
15
  authors = [{name = "Michael Kleehammer", email="michael@kleehammer.com"}]
16
16
 
@@ -22,7 +22,6 @@ maintainers = [{name = "Michael Kleehammer", email="michael@kleehammer.com"}]
22
22
  classifiers=['Development Status :: 5 - Production/Stable',
23
23
  'Intended Audience :: Developers',
24
24
  'Intended Audience :: System Administrators',
25
- 'License :: OSI Approved :: MIT No Attribution License (MIT-0)',
26
25
  'Operating System :: Microsoft :: Windows',
27
26
  'Operating System :: POSIX',
28
27
  'Programming Language :: Python',
@@ -56,11 +56,11 @@ def main():
56
56
  package_dir={'': 'src'},
57
57
  package_data={'': ['pyodbc.pyi']}, # places pyodbc.pyi alongside pyodbc.{platform}.{pyd|so} in site-packages
58
58
  license='MIT-0',
59
- python_requires='>=3.8',
59
+ python_requires='>=3.9',
60
60
  classifiers=['Development Status :: 5 - Production/Stable',
61
61
  'Intended Audience :: Developers',
62
62
  'Intended Audience :: System Administrators',
63
- 'License :: OSI Approved :: MIT No Attribution License (MIT-0)',
63
+ 'License :: OSI Approved :: MIT-0',
64
64
  'Operating System :: Microsoft :: Windows',
65
65
  'Operating System :: POSIX',
66
66
  'Programming Language :: Python',
@@ -147,10 +147,15 @@ def get_compiler_settings():
147
147
  '/opt/homebrew/include',
148
148
  expanduser('~/homebrew/include'),
149
149
  ]
150
+ _HOMEBREW_PREFIX = os.environ.get('HOMEBREW_PREFIX')
151
+ if _HOMEBREW_PREFIX is not None:
152
+ dirs.insert(0, os.path.join(_HOMEBREW_PREFIX, 'include'))
150
153
  settings['include_dirs'].extend(dir for dir in dirs if isdir(dir))
151
154
  # unixODBC make/install places libodbc.dylib in /usr/local/lib/ by default
152
155
  # ( also OS/X since El Capitan prevents /usr/lib from being accessed )
153
156
  settings['library_dirs'] = ['/usr/local/lib', '/opt/homebrew/lib']
157
+ if _HOMEBREW_PREFIX is not None:
158
+ settings['library_dirs'].insert(1, os.path.join(_HOMEBREW_PREFIX, 'lib'))
154
159
  else:
155
160
  # Other posix-like: Linux, Solaris, etc.
156
161
 
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyodbc
3
+ Version: 5.3.0
4
+ Summary: DB API module for ODBC
5
+ Home-page: https://github.com/mkleehammer/pyodbc
6
+ Author-email: Michael Kleehammer <michael@kleehammer.com>
7
+ Maintainer: Michael Kleehammer
8
+ Maintainer-email: Michael Kleehammer <michael@kleehammer.com>
9
+ License: MIT
10
+ Project-URL: Homepage, https://github.com/mkleehammer/pyodbc
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Database
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE.txt
22
+ Dynamic: home-page
23
+ Dynamic: license-file
24
+ Dynamic: maintainer
25
+ Dynamic: requires-python
26
+
27
+ # pyodbc
28
+
29
+ [![Windows build](https://ci.appveyor.com/api/projects/status/github/mkleehammer/pyodbc?branch=master&svg=true&passingText=Windows%20build&failingText=Windows%20build)](https://ci.appveyor.com/project/mkleehammer/pyodbc)
30
+ [![Ubuntu build](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml/badge.svg)](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml)
31
+ [![PyPI](https://img.shields.io/pypi/v/pyodbc?color=brightgreen)](https://pypi.org/project/pyodbc/)
32
+
33
+ pyodbc is an open source Python module that makes accessing ODBC databases simple. It
34
+ implements the [DB API 2.0](https://www.python.org/dev/peps/pep-0249) specification but is packed with even more Pythonic convenience.
35
+
36
+ The easiest way to install pyodbc is to use pip:
37
+
38
+ python -m pip install pyodbc
39
+
40
+ On Macs, you should probably install unixODBC first if you don't already have an ODBC
41
+ driver manager installed. For example, using the [homebrew](https://brew.sh/) package manager:
42
+
43
+ brew install unixodbc
44
+ python -m pip install pyodbc
45
+
46
+ Similarly, on Unix you should make sure you have an ODBC driver manager installed before
47
+ installing pyodbc. See the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install)
48
+ for more information about how to do this on different Unix flavors. (On Windows, the
49
+ ODBC driver manager is built-in.)
50
+
51
+ Precompiled binary wheels are provided for multiple Python versions on most Windows, macOS,
52
+ and Linux platforms. On other platforms pyodbc will be built from the source code. Note,
53
+ pyodbc contains C++ extensions so you will need a suitable C++ compiler when building from
54
+ source. See the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install) for details.
55
+
56
+ [Documentation](https://github.com/mkleehammer/pyodbc/wiki)
57
+
58
+ [Release Notes](https://github.com/mkleehammer/pyodbc/releases)
@@ -37,4 +37,5 @@ tests/__init__.py
37
37
  tests/conftest.py
38
38
  tests/mysql_test.py
39
39
  tests/postgresql_test.py
40
+ tests/sqlite_test.py
40
41
  tests/sqlserver_test.py
@@ -1264,14 +1264,13 @@ static PyObject* MakeConnectionString(PyObject* existing, PyObject* parts)
1264
1264
  // parts
1265
1265
  // A dictionary of text keywords and text values that will be appended.
1266
1266
 
1267
- assert(PyUnicode_Check(existing));
1268
-
1269
1267
  Py_ssize_t pos = 0;
1270
1268
  PyObject* key = 0;
1271
1269
  PyObject* value = 0;
1272
1270
  Py_ssize_t length = 0; // length in *characters*
1273
1271
  int result_kind = PyUnicode_1BYTE_KIND;
1274
1272
  if (existing) {
1273
+ assert(PyUnicode_Check(existing));
1275
1274
  length = PyUnicode_GET_LENGTH(existing) + 1; // + 1 to add a trailing semicolon
1276
1275
  int kind = PyUnicode_KIND(existing);
1277
1276
  if (result_kind < kind)
@@ -28,8 +28,8 @@ def _add_to_path():
28
28
  Prepends the build directory to the path so that newly built pyodbc libraries are
29
29
  used, allowing it to be tested without pip-installing it.
30
30
  """
31
- # look for the suffixes used in the build filenames, e.g. ".cp38-win_amd64.pyd",
32
- # ".cpython-38-darwin.so", ".cpython-38-x86_64-linux-gnu.so", etc.
31
+ # look for the suffixes used in the build filenames, e.g. ".cp313-win_amd64.pyd",
32
+ # ".cpython-313-darwin.so", ".cpython-313-x86_64-linux-gnu.so", etc.
33
33
  library_exts = [ext for ext in importlib.machinery.EXTENSION_SUFFIXES if ext != '.pyd']
34
34
  # generate the name of the pyodbc build file(s)
35
35
  library_names = [f'pyodbc{ext}' for ext in library_exts]
@@ -0,0 +1,638 @@
1
+ #!/usr/bin/python
2
+
3
+ usage = """\
4
+ %(prog)s [options] connection_string
5
+
6
+ Unit tests for SQLite using the ODBC driver from http://www.ch-werner.de/sqliteodbc
7
+
8
+ To use, pass a connection string as the parameter. The tests will create and
9
+ drop tables t1 and t2 as necessary. On Windows, use the 32-bit driver with
10
+ 32-bit Python and the 64-bit driver with 64-bit Python (regardless of your
11
+ operating system bitness).
12
+
13
+ These run using the version from the 'build' directory, not the version
14
+ installed into the Python directories. You must run python setup.py build
15
+ before running the tests.
16
+
17
+ You can also put the connection string into a tmp/setup.cfg file like so:
18
+
19
+ [sqlitetests]
20
+ connection-string=Driver=SQLite3 ODBC Driver;Database=sqlite.db
21
+ """
22
+
23
+ import sys, os, re
24
+ import pytest
25
+ import pyodbc
26
+ from decimal import Decimal
27
+ from datetime import datetime, date, time
28
+ from os.path import join, getsize, dirname, abspath
29
+ from typing import Iterator
30
+
31
+ _TESTSTR = '0123456789-abcdefghijklmnopqrstuvwxyz-'
32
+
33
+ def _generate_test_string(length):
34
+ """
35
+ Returns a string of `length` characters, constructed by repeating _TESTSTR as necessary.
36
+
37
+ To enhance performance, there are 3 ways data is read, based on the length of the value, so most data types are
38
+ tested with 3 lengths. This function helps us generate the test data.
39
+
40
+ We use a recognizable data set instead of a single character to make it less likely that "overlap" errors will
41
+ be hidden and to help us manually identify where a break occurs.
42
+ """
43
+ if length <= len(_TESTSTR):
44
+ return _TESTSTR[:length]
45
+
46
+ c = (length + len(_TESTSTR)-1) // len(_TESTSTR)
47
+ v = _TESTSTR * c
48
+ return v[:length]
49
+
50
+ SMALL_FENCEPOST_SIZES = [ 0, 1, 255, 256, 510, 511, 512, 1023, 1024, 2047, 2048, 4000 ]
51
+ LARGE_FENCEPOST_SIZES = [ 4095, 4096, 4097, 10 * 1024, 20 * 1024 ]
52
+
53
+ STR_FENCEPOSTS = [ _generate_test_string(size) for size in SMALL_FENCEPOST_SIZES ]
54
+ BYTE_FENCEPOSTS = [ bytes(s, 'ascii') for s in STR_FENCEPOSTS ]
55
+ IMAGE_FENCEPOSTS = BYTE_FENCEPOSTS + [ bytes(_generate_test_string(size), 'ascii') for size in LARGE_FENCEPOST_SIZES ]
56
+
57
+ @pytest.fixture
58
+ def connection_string(tmp_path):
59
+ return os.environ.get('PYODBC_SQLITE', f'driver=SQLite3;database={tmp_path}/test.db')
60
+
61
+ @pytest.fixture()
62
+ def cnxn(connection_string):
63
+ c = pyodbc.connect(connection_string, autocommit=False, attrs_before=None)
64
+ yield c
65
+
66
+ if not c.closed:
67
+ c.close()
68
+
69
+ @pytest.fixture()
70
+ def cursor(cnxn) -> Iterator[pyodbc.Cursor]:
71
+ cur = cnxn.cursor()
72
+
73
+ cur.execute("drop table if exists t0")
74
+ cur.execute("drop table if exists t1")
75
+ cur.execute("drop table if exists t2")
76
+ cnxn.commit()
77
+
78
+ yield cur
79
+
80
+ def test_multiple_bindings(cursor):
81
+ "More than one bind and select on a cursor"
82
+ cursor.execute("create table t1(n int)")
83
+ cursor.execute("insert into t1 values (?)", 1)
84
+ cursor.execute("insert into t1 values (?)", 2)
85
+ cursor.execute("insert into t1 values (?)", 3)
86
+ for i in range(3):
87
+ cursor.execute("select n from t1 where n < ?", 10)
88
+ cursor.execute("select n from t1 where n < 3")
89
+
90
+
91
+ def test_different_bindings(cursor):
92
+ cursor.execute("create table t1(n int)")
93
+ cursor.execute("create table t2(d datetime)")
94
+ cursor.execute("insert into t1 values (?)", 1)
95
+ cursor.execute("insert into t2 values (?)", datetime.now())
96
+
97
+ def test_drivers():
98
+ p = pyodbc.drivers()
99
+ assert isinstance(p, list)
100
+
101
+ def test_datasources():
102
+ p = pyodbc.dataSources()
103
+ assert isinstance(p, dict)
104
+
105
+ def test_getinfo_string(cnxn):
106
+ value = cnxn.getinfo(pyodbc.SQL_CATALOG_NAME_SEPARATOR)
107
+ assert isinstance(value, str)
108
+
109
+ def test_getinfo_bool(cnxn):
110
+ value = cnxn.getinfo(pyodbc.SQL_ACCESSIBLE_TABLES)
111
+ assert isinstance(value, bool)
112
+
113
+ def test_getinfo_int(cnxn):
114
+ value = cnxn.getinfo(pyodbc.SQL_DEFAULT_TXN_ISOLATION)
115
+ assert isinstance(value, int)
116
+
117
+ def test_getinfo_smallint(cnxn):
118
+ value = cnxn.getinfo(pyodbc.SQL_CONCAT_NULL_BEHAVIOR)
119
+ assert isinstance(value, int)
120
+
121
+ def _test_strtype(cursor, sqltype, value, colsize=None):
122
+ """
123
+ The implementation for string, Unicode, and binary tests.
124
+ """
125
+ assert colsize is None or (value is None or colsize >= len(value))
126
+
127
+ if colsize:
128
+ sql = "create table t1(s {}({}))".format(sqltype, colsize)
129
+ else:
130
+ sql = "create table t1(s %s)" % sqltype
131
+
132
+ cursor.execute(sql)
133
+ cursor.execute("insert into t1 values(?)", value)
134
+ v = cursor.execute("select * from t1").fetchone()[0]
135
+ assert type(v) == type(value)
136
+
137
+ if value is not None:
138
+ assert len(v) == len(value)
139
+
140
+ assert v == value
141
+
142
+ # Reported by Andy Hochhaus in the pyodbc group: In 2.1.7 and earlier, a hardcoded length of 255 was used to
143
+ # determine whether a parameter was bound as a SQL_VARCHAR or SQL_LONGVARCHAR. Apparently SQL Server chokes if
144
+ # we bind as a SQL_LONGVARCHAR and the target column size is 8000 or less, which is considers just SQL_VARCHAR.
145
+ # This means binding a 256 character value would cause problems if compared with a VARCHAR column under
146
+ # 8001. We now use SQLGetTypeInfo to determine the time to switch.
147
+ #
148
+ # [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]The data types varchar and text are incompatible in the equal to operator.
149
+
150
+ cursor.execute("select * from t1 where s=?", value)
151
+
152
+
153
+ def _test_strliketype(cursor, sqltype, value, colsize=None):
154
+ """
155
+ The implementation for text, image, ntext, and binary.
156
+
157
+ These types do not support comparison operators.
158
+ """
159
+ assert colsize is None or (value is None or colsize >= len(value))
160
+
161
+ if colsize:
162
+ sql = "create table t1(s {}({}))".format(sqltype, colsize)
163
+ else:
164
+ sql = "create table t1(s %s)" % sqltype
165
+
166
+ cursor.execute(sql)
167
+ cursor.execute("insert into t1 values(?)", value)
168
+ v = cursor.execute("select * from t1").fetchone()[0]
169
+ assert type(v) == type(value)
170
+
171
+ if value is not None:
172
+ assert len(v) == len(value)
173
+
174
+ assert v == value
175
+
176
+ #
177
+ # text
178
+ #
179
+
180
+ def test_text_null(cursor):
181
+ _test_strtype(cursor, 'text', None, 100)
182
+
183
+ # Generate a test for each fencepost size: test_text_0, etc.
184
+ def _maketest(value):
185
+ def t(cursor):
186
+ _test_strtype(cursor, 'text', value, len(value))
187
+ return t
188
+ for value in STR_FENCEPOSTS:
189
+ locals()['test_text_%s' % len(value)] = _maketest(value)
190
+
191
+ def test_text_upperlatin(cursor):
192
+ _test_strtype(cursor, 'varchar', 'á')
193
+
194
+ #
195
+ # blob
196
+ #
197
+
198
+ def test_null_blob(cursor):
199
+ _test_strtype(cursor, 'blob', None, 100)
200
+
201
+ def test_large_null_blob(cursor):
202
+ # Bug 1575064
203
+ _test_strtype(cursor, 'blob', None, 4000)
204
+
205
+ # Generate a test for each fencepost size: test_unicode_0, etc.
206
+ def _maketest(value):
207
+ def t(cursor):
208
+ _test_strtype(cursor, 'blob', value, len(value))
209
+ return t
210
+ for value in BYTE_FENCEPOSTS:
211
+ locals()['test_blob_%s' % len(value)] = _maketest(value)
212
+
213
+ def test_subquery_params(cursor):
214
+ """Ensure parameter markers work in a subquery"""
215
+ cursor.execute("create table t1(id integer, s varchar(20))")
216
+ cursor.execute("insert into t1 values (?,?)", 1, 'test')
217
+ row = cursor.execute("""
218
+ select x.id
219
+ from (
220
+ select id
221
+ from t1
222
+ where s = ?
223
+ and id between ? and ?
224
+ ) x
225
+ """, 'test', 1, 10).fetchone()
226
+ assert row != None
227
+ assert row[0] == 1
228
+
229
+ def test_close_cnxn(cursor, cnxn):
230
+ """Make sure using a Cursor after closing its connection doesn't crash."""
231
+
232
+ cursor.execute("create table t1(id integer, s varchar(20))")
233
+ cursor.execute("insert into t1 values (?,?)", 1, 'test')
234
+ cursor.execute("select * from t1")
235
+
236
+ cnxn.close()
237
+
238
+ # Now that the connection is closed, we expect an exception. (If the code attempts to use
239
+ # the HSTMT, we'll get an access violation instead.)
240
+ sql = "select * from t1"
241
+ with pytest.raises(pyodbc.ProgrammingError):
242
+ cursor.execute(sql)
243
+
244
+ def test_negative_row_index(cursor):
245
+ cursor.execute("create table t1(s varchar(20))")
246
+ cursor.execute("insert into t1 values(?)", "1")
247
+ row = cursor.execute("select * from t1").fetchone()
248
+ assert row[0] == "1"
249
+ assert row[-1] == "1"
250
+
251
+ def test_version(cursor):
252
+ assert 3 == len(pyodbc.version.split('.')) # 1.3.1 etc.
253
+
254
+ #
255
+ # ints and floats
256
+ #
257
+
258
+ def test_int(cursor):
259
+ value = 1234
260
+ cursor.execute("create table t1(n int)")
261
+ cursor.execute("insert into t1 values (?)", value)
262
+ result = cursor.execute("select n from t1").fetchone()[0]
263
+ assert result == value
264
+
265
+ def test_negative_int(cursor):
266
+ value = -1
267
+ cursor.execute("create table t1(n int)")
268
+ cursor.execute("insert into t1 values (?)", value)
269
+ result = cursor.execute("select n from t1").fetchone()[0]
270
+ assert result == value
271
+
272
+ def test_bigint(cursor):
273
+ input = 3000000000
274
+ cursor.execute("create table t1(d bigint)")
275
+ cursor.execute("insert into t1 values (?)", input)
276
+ result = cursor.execute("select d from t1").fetchone()[0]
277
+ assert result == input
278
+
279
+ def test_negative_bigint(cursor):
280
+ # Issue 186: BIGINT problem on 32-bit architecture
281
+ input = -430000000
282
+ cursor.execute("create table t1(d bigint)")
283
+ cursor.execute("insert into t1 values (?)", input)
284
+ result = cursor.execute("select d from t1").fetchone()[0]
285
+ assert result == input
286
+
287
+ def test_float(cursor):
288
+ value = 1234.567
289
+ cursor.execute("create table t1(n float)")
290
+ cursor.execute("insert into t1 values (?)", value)
291
+ result = cursor.execute("select n from t1").fetchone()[0]
292
+ assert result == value
293
+
294
+ def test_negative_float(cursor):
295
+ value = -200
296
+ cursor.execute("create table t1(n float)")
297
+ cursor.execute("insert into t1 values (?)", value)
298
+ result = cursor.execute("select n from t1").fetchone()[0]
299
+ assert value == result
300
+
301
+ #
302
+ # rowcount
303
+ #
304
+
305
+ # Note: SQLRowCount does not define what the driver must return after a select statement
306
+ # and says that its value should not be relied upon. The sqliteodbc driver is hardcoded to
307
+ # return 0 so I've deleted the test.
308
+
309
+ def test_rowcount_delete(cursor):
310
+ assert cursor.rowcount == 0
311
+ cursor.execute("create table t1(i int)")
312
+ count = 4
313
+ for i in range(count):
314
+ cursor.execute("insert into t1 values (?)", i)
315
+ cursor.execute("delete from t1")
316
+ assert cursor.rowcount == count
317
+
318
+ def test_rowcount_nodata(cursor):
319
+ """
320
+ This represents a different code path than a delete that deleted something.
321
+
322
+ The return value is SQL_NO_DATA and code after it was causing an error. We could use SQL_NO_DATA to step over
323
+ the code that errors out and drop down to the same SQLRowCount code. On the other hand, we could hardcode a
324
+ zero return value.
325
+ """
326
+ cursor.execute("create table t1(i int)")
327
+ # This is a different code path internally.
328
+ cursor.execute("delete from t1")
329
+ assert cursor.rowcount == 0
330
+
331
+ # In the 2.0.x branch, Cursor.execute sometimes returned the cursor and sometimes the rowcount. This proved very
332
+ # confusing when things went wrong and added very little value even when things went right since users could always
333
+ # use: cursor.execute("...").rowcount
334
+
335
+ def test_retcursor_delete(cursor):
336
+ cursor.execute("create table t1(i int)")
337
+ cursor.execute("insert into t1 values (1)")
338
+ v = cursor.execute("delete from t1")
339
+ assert v == cursor
340
+
341
+ def test_retcursor_nodata(cursor):
342
+ """
343
+ This represents a different code path than a delete that deleted something.
344
+
345
+ The return value is SQL_NO_DATA and code after it was causing an error. We could use SQL_NO_DATA to step over
346
+ the code that errors out and drop down to the same SQLRowCount code.
347
+ """
348
+ cursor.execute("create table t1(i int)")
349
+ # This is a different code path internally.
350
+ v = cursor.execute("delete from t1")
351
+ assert v == cursor
352
+
353
+ def test_retcursor_select(cursor):
354
+ cursor.execute("create table t1(i int)")
355
+ cursor.execute("insert into t1 values (1)")
356
+ v = cursor.execute("select * from t1")
357
+ assert v == cursor
358
+
359
+ #
360
+ # misc
361
+ #
362
+
363
+ def test_lower_case(cnxn):
364
+ "Ensure pyodbc.lowercase forces returned column names to lowercase."
365
+
366
+ # Has to be set before creating the cursor, so we must recreate cursor.
367
+
368
+ pyodbc.lowercase = True
369
+ cursor = cnxn.cursor()
370
+
371
+ cursor.execute("create table t1(Abc int, dEf int)")
372
+ cursor.execute("select * from t1")
373
+
374
+ names = [ t[0] for t in cursor.description ]
375
+ names.sort()
376
+
377
+ assert names == [ "abc", "def" ]
378
+
379
+ # Put it back so other tests don't fail.
380
+ pyodbc.lowercase = False
381
+
382
+ def test_row_description(cnxn):
383
+ """
384
+ Ensure Cursor.description is accessible as Row.cursor_description.
385
+ """
386
+ cursor = cnxn.cursor()
387
+ cursor.execute("create table t1(a int, b char(3))")
388
+ cnxn.commit()
389
+ cursor.execute("insert into t1 values(1, 'abc')")
390
+
391
+ row = cursor.execute("select * from t1").fetchone()
392
+
393
+ assert cursor.description == row.cursor_description
394
+
395
+
396
+ def test_executemany(cursor):
397
+ cursor.execute("create table t1(a int, b varchar(10))")
398
+
399
+ params = [ (i, str(i)) for i in range(1, 6) ]
400
+
401
+ cursor.executemany("insert into t1(a, b) values (?,?)", params)
402
+
403
+ count = cursor.execute("select count(*) from t1").fetchone()[0]
404
+ assert count == len(params)
405
+
406
+ cursor.execute("select a, b from t1 order by a")
407
+ rows = cursor.fetchall()
408
+ assert count == len(rows)
409
+
410
+ for param, row in zip(params, rows):
411
+ assert param[0] == row[0]
412
+ assert param[1] == row[1]
413
+
414
+
415
+ def test_executemany_one(cursor):
416
+ "Pass executemany a single sequence"
417
+ cursor.execute("create table t1(a int, b varchar(10))")
418
+
419
+ params = [ (1, "test") ]
420
+
421
+ cursor.executemany("insert into t1(a, b) values (?,?)", params)
422
+
423
+ count = cursor.execute("select count(*) from t1").fetchone()[0]
424
+ assert count == len(params)
425
+
426
+ cursor.execute("select a, b from t1 order by a")
427
+ rows = cursor.fetchall()
428
+ assert count == len(rows)
429
+
430
+ for param, row in zip(params, rows):
431
+ assert param[0] == row[0]
432
+ assert param[1] == row[1]
433
+
434
+
435
+ def test_executemany_failure(cursor):
436
+ """
437
+ Ensure that an exception is raised if one query in an executemany fails.
438
+ """
439
+ cursor.execute("create table t1(a int, b varchar(10))")
440
+
441
+ params = [ (1, 'good'),
442
+ ('error', 'not an int'),
443
+ (3, 'good') ]
444
+
445
+ with pytest.raises(pyodbc.Error):
446
+ cursor.executemany("insert into t1(a, b) value (?, ?)", params)
447
+
448
+
449
+ def test_row_slicing(cursor):
450
+ cursor.execute("create table t1(a int, b int, c int, d int)");
451
+ cursor.execute("insert into t1 values(1,2,3,4)")
452
+
453
+ row = cursor.execute("select * from t1").fetchone()
454
+
455
+ result = row[:]
456
+ assert result is row
457
+
458
+ result = row[:-1]
459
+ assert result == (1,2,3)
460
+
461
+ result = row[0:4]
462
+ assert result is row
463
+
464
+
465
+ def test_row_repr(cursor):
466
+ cursor.execute("create table t1(a int, b int, c int, d int)");
467
+ cursor.execute("insert into t1 values(1,2,3,4)")
468
+
469
+ row = cursor.execute("select * from t1").fetchone()
470
+
471
+ result = str(row)
472
+ assert result == "(1, 2, 3, 4)"
473
+
474
+ result = str(row[:-1])
475
+ assert result == "(1, 2, 3)"
476
+
477
+ result = str(row[:1])
478
+ assert result == "(1,)"
479
+
480
+
481
+ def test_view_select(cursor):
482
+ # Reported in forum: Can't select from a view? I think I do this a lot, but another test never hurts.
483
+
484
+ # Create a table (t1) with 3 rows and a view (t2) into it.
485
+ cursor.execute("create table t1(c1 int identity(1, 1), c2 varchar(50))")
486
+ for i in range(3):
487
+ cursor.execute("insert into t1(c2) values (?)", "string%s" % i)
488
+ cursor.execute("create view t2 as select * from t1")
489
+
490
+ # Select from the view
491
+ cursor.execute("select * from t2")
492
+ rows = cursor.fetchall()
493
+ assert rows is not None
494
+ assert len(rows) == 3
495
+
496
+ def test_autocommit(cnxn, connection_string):
497
+ assert cnxn.autocommit == False
498
+
499
+ othercnxn = pyodbc.connect(connection_string, autocommit=True)
500
+ assert othercnxn.autocommit == True
501
+
502
+ othercnxn.autocommit = False
503
+ assert othercnxn.autocommit == False
504
+
505
+ def test_skip(cursor):
506
+ # Insert 1, 2, and 3. Fetch 1, skip 2, fetch 3.
507
+
508
+ cursor.execute("create table t1(id int)");
509
+ for i in range(1, 5):
510
+ cursor.execute("insert into t1 values(?)", i)
511
+ cursor.execute("select id from t1 order by id")
512
+ assert cursor.fetchone()[0] == 1
513
+ cursor.skip(2)
514
+ assert cursor.fetchone()[0] == 4
515
+
516
+ def test_sets_execute(cursor):
517
+ # Only lists and tuples are allowed.
518
+ with pytest.raises(pyodbc.ProgrammingError):
519
+ cursor.execute("create table t1 (word varchar (100))")
520
+ words = set (['a'])
521
+ cursor.execute("insert into t1 (word) VALUES (?)", [words])
522
+
523
+ def test_sets_executemany(cursor):
524
+ # Only lists and tuples are allowed.
525
+ with pytest.raises(TypeError):
526
+ cursor.execute("create table t1 (word varchar (100))")
527
+ words = set (['a'])
528
+ cursor.executemany("insert into t1 (word) values (?)", [words])
529
+
530
+ def test_row_execute(cursor):
531
+ "Ensure we can use a Row object as a parameter to execute"
532
+ cursor.execute("create table t1(n int, s varchar(10))")
533
+ cursor.execute("insert into t1 values (1, 'a')")
534
+ row = cursor.execute("select n, s from t1").fetchone()
535
+ assert row != None
536
+
537
+ cursor.execute("create table t2(n int, s varchar(10))")
538
+ cursor.execute("insert into t2 values (?, ?)", row)
539
+
540
+ def test_row_executemany(cursor):
541
+ "Ensure we can use a Row object as a parameter to executemany"
542
+ cursor.execute("create table t1(n int, s varchar(10))")
543
+
544
+ for i in range(3):
545
+ cursor.execute("insert into t1 values (?, ?)", i, chr(ord('a')+i))
546
+
547
+ rows = cursor.execute("select n, s from t1").fetchall()
548
+ assert len(rows) != 0
549
+
550
+ cursor.execute("create table t2(n int, s varchar(10))")
551
+ cursor.executemany("insert into t2 values (?, ?)", rows)
552
+
553
+ def test_description(cursor):
554
+ "Ensure cursor.description is correct"
555
+
556
+ cursor.execute("create table t1(n int, s text)")
557
+ cursor.execute("insert into t1 values (1, 'abc')")
558
+ cursor.execute("select * from t1")
559
+
560
+ # (I'm not sure the precision of an int is constant across different versions, bits, so I'm hand checking the
561
+ # items I do know.
562
+
563
+ # int
564
+ t = cursor.description[0]
565
+ assert t[0] == 'n'
566
+ assert t[1] == int
567
+ assert t[5] == 0 # scale
568
+ assert t[6] == True # nullable
569
+
570
+ # text
571
+ t = cursor.description[1]
572
+ assert t[0] == 's'
573
+ assert t[1] == str
574
+ assert t[5] == 0 # scale
575
+ assert t[6] == True # nullable
576
+
577
+ def test_row_equal(cursor):
578
+ cursor.execute("create table t1(n int, s varchar(20))")
579
+ cursor.execute("insert into t1 values (1, 'test')")
580
+ row1 = cursor.execute("select n, s from t1").fetchone()
581
+ row2 = cursor.execute("select n, s from t1").fetchone()
582
+ b = (row1 == row2)
583
+ assert b == True
584
+
585
+ def test_row_gtlt(cursor):
586
+ cursor.execute("create table t1(n int, s varchar(20))")
587
+ cursor.execute("insert into t1 values (1, 'test1')")
588
+ cursor.execute("insert into t1 values (1, 'test2')")
589
+ rows = cursor.execute("select n, s from t1 order by s").fetchall()
590
+ assert rows[0] < rows[1]
591
+ assert rows[0] <= rows[1]
592
+ assert rows[1] > rows[0]
593
+ assert rows[1] >= rows[0]
594
+ assert rows[0] != rows[1]
595
+
596
+ rows = list(rows)
597
+ rows.sort() # uses <
598
+
599
+ def _test_context_manager(connection_string):
600
+ # TODO: This is failing, but it may be due to the design of sqlite. I've disabled it
601
+ # for now until I can research it some more.
602
+
603
+ # WARNING: This isn't working right now. We've set the driver's autocommit to "off",
604
+ # but that doesn't automatically start a transaction. I'm not familiar enough with the
605
+ # internals of the driver to tell what is going on, but it looks like there is support
606
+ # for the autocommit flag.
607
+ #
608
+ # I thought it might be a timing issue, like it not actually starting a txn until you
609
+ # try to do something, but that doesn't seem to work either. I'll leave this in to
610
+ # remind us that it isn't working yet but we need to contact the SQLite ODBC driver
611
+ # author for some guidance.
612
+
613
+ with pyodbc.connect(connection_string) as cnxn:
614
+ cursor = cnxn.cursor()
615
+ cursor.execute("begin")
616
+ cursor.execute("create table t1(i int)")
617
+ cursor.execute('rollback')
618
+
619
+ # The connection should be closed now.
620
+ with pytest.raises(pyodbc.Error):
621
+ cnxn.execute('rollback')
622
+
623
+ def test_untyped_none(cursor):
624
+ # From issue 129
625
+ value = cursor.execute("select ?", None).fetchone()[0]
626
+ assert value == None
627
+
628
+ def test_large_update_nodata(cursor):
629
+ cursor.execute('create table t1(a blob)')
630
+ hundredkb = 'x'*100*1024
631
+ cursor.execute('update t1 set a=? where 1=0', (hundredkb,))
632
+
633
+ def test_no_fetch(cursor):
634
+ # Issue 89 with FreeTDS: Multiple selects (or catalog functions that issue selects) without fetches seem to
635
+ # confuse the driver.
636
+ cursor.execute('select 1')
637
+ cursor.execute('select 1')
638
+ cursor.execute('select 1')
pyodbc-5.2.0/PKG-INFO DELETED
@@ -1,25 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pyodbc
3
- Version: 5.2.0
4
- Summary: DB API Module for ODBC
5
- Home-page: https://github.com/mkleehammer/pyodbc
6
- Maintainer: Michael Kleehammer
7
- Maintainer-email: michael@kleehammer.com
8
- License: MIT-0
9
- Platform: UNKNOWN
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Intended Audience :: System Administrators
13
- Classifier: License :: OSI Approved :: MIT No Attribution License (MIT-0)
14
- Classifier: Operating System :: Microsoft :: Windows
15
- Classifier: Operating System :: POSIX
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Topic :: Database
19
- Requires-Python: >=3.8
20
- License-File: LICENSE.txt
21
-
22
- pyodbc is an open source Python module that makes accessing ODBC databases simple.
23
- It implements the [DB API 2.0](https://www.python.org/dev/peps/pep-0249)
24
- specification but is packed with even more Pythonic convenience.
25
-
@@ -1,25 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pyodbc
3
- Version: 5.2.0
4
- Summary: DB API Module for ODBC
5
- Home-page: https://github.com/mkleehammer/pyodbc
6
- Maintainer: Michael Kleehammer
7
- Maintainer-email: michael@kleehammer.com
8
- License: MIT-0
9
- Platform: UNKNOWN
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Intended Audience :: System Administrators
13
- Classifier: License :: OSI Approved :: MIT No Attribution License (MIT-0)
14
- Classifier: Operating System :: Microsoft :: Windows
15
- Classifier: Operating System :: POSIX
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Topic :: Database
19
- Requires-Python: >=3.8
20
- License-File: LICENSE.txt
21
-
22
- pyodbc is an open source Python module that makes accessing ODBC databases simple.
23
- It implements the [DB API 2.0](https://www.python.org/dev/peps/pep-0249)
24
- specification but is packed with even more Pythonic convenience.
25
-
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