Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement setinputsizes. #453

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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