Skip to content

Commit

Permalink
Implement setinputsizes. (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
jettify committed Oct 28, 2023
1 parent 54efbd8 commit 9711e9c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
@@ -1,5 +1,13 @@
Changes
-------
0.4.1 (2023-10-28)
^^^^^^^^^^^^^^^^^^
* Implemented cursor setinputsizes.
* Implemented cursor fetchval.
* Added more type annotations.
* Added autocommit setter for cusror.


0.4.0 (2023-03-16)
^^^^^^^^^^^^^^^^^^
* Fixed compatibility with python 3.9+.
Expand Down
18 changes: 15 additions & 3 deletions aioodbc/cursor.py
Expand Up @@ -145,9 +145,21 @@ def executemany(self, sql, *params):
def callproc(self, procname, args=()):
raise NotImplementedError

async def setinputsizes(self, *args, **kwargs):
"""Does nothing, required by DB API."""
return None
async def setinputsizes(self, sizes=None) -> None:
"""Explicitly declare the types and sizes of the parameters in a query.
Set to None to clear any previously registered input sizes.
:param sizes: A list of tuples, one tuple for each query parameter,
where each tuple contains:
1. the column datatype
2. the column size (char length or decimal precision)
3. the decimal scale.
For example:
[(pyodbc.SQL_WVARCHAR, 50, 0), (pyodbc.SQL_DECIMAL, 18, 4)]
"""
# sizes: Optional[Iterable[Tuple[int, int, int]]]
await self._run_operation(self._impl.setinputsizes, sizes)

async def setoutputsize(self, *args, **kwargs):
"""Does nothing, required by DB API."""
Expand Down
6 changes: 5 additions & 1 deletion tests/test_cursor.py
Expand Up @@ -56,7 +56,11 @@ async def test_cursor(conn):
assert cur.arraysize == 1
assert cur.rowcount == -1

r = await cur.setinputsizes()
r = await cur.setinputsizes(
[
(pyodbc.SQL_WVARCHAR, 50, 0),
]
)
assert r is None

await cur.setoutputsize()
Expand Down

0 comments on commit 9711e9c

Please sign in to comment.