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

Fetchdictarray rebased #1270

Closed
wants to merge 14 commits into from
18 changes: 16 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -66,5 +66,19 @@ jobs:
# make bootstrap
# make release

- name: Build and install pyodbc
run: |
cd "$GITHUB_WORKSPACE"
echo "*** current python version"
python -VV
echo "*** pip install"
python -m pip install .
echo "*** pip freeze"
python -m pip freeze --all
echo "*** pyodbc version"
python -c "import pyodbc; print(pyodbc.version)"
echo "*** pyodbc drivers"
python -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion appveyor/after_test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ IF "%APVYR_GENERATE_WHEELS%" == "true" (
"%PYTHON_HOME%\python" -m pip install build wheel --quiet --no-warn-script-location
ECHO.
ECHO *** Generate the wheel file
%WITH_COMPILER% "%PYTHON_HOME%\python" -m build --wheel --no-isolation
%WITH_COMPILER% "%PYTHON_HOME%\python" -m build --wheel
ECHO.
ECHO *** \dist directory listing:
DIR /B dist
Expand Down
2 changes: 1 addition & 1 deletion appveyor/install.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ECHO *** pip install pytest and other dev requirements ***
"%PYTHON_HOME%\python" -m pip install -r requirements-dev.txt --quiet --no-warn-script-location
"%PYTHON_HOME%\python" -m pip install .[qa,test] --quiet --no-warn-script-location
ECHO.
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ classifiers=['Development Status :: 5 - Production/Stable',
[project.urls]
Homepage = "https://github.com/mkleehammer/pyodbc"

[project.optional-dependencies]
numpy = ["numpy"]
qa = ["flake8", "pylint"]
test = ["pytest ~= 7.3"]

[build-system]
requires = ["setuptools"]
requires = ["setuptools ~= 67.7", "numpy"]
build-backend = "setuptools.build_meta"
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pathlib import Path
from inspect import cleandoc

import numpy
from setuptools import setup
from setuptools.extension import Extension

Expand Down Expand Up @@ -82,6 +83,7 @@ def get_compiler_settings():
'include_dirs': [],
'define_macros': [('PYODBC_VERSION', VERSION)]
}
settings['include_dirs'].append(numpy.get_include())

if os.name == 'nt':
settings['extra_compile_args'].extend([
Expand Down
20 changes: 8 additions & 12 deletions src/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
#include "dbspecific.h"
#include <datetime.h>

enum
{
CURSOR_REQUIRE_CNXN = 0x00000001,
CURSOR_REQUIRE_OPEN = 0x00000003, // includes _CNXN
CURSOR_REQUIRE_RESULTS = 0x00000007, // includes _OPEN
CURSOR_RAISE_ERROR = 0x00000010,
};
#include "npcontainer.h"

inline bool StatementIsValid(Cursor* cursor)
{
Expand All @@ -45,7 +39,7 @@ inline bool Cursor_Check(PyObject* o)
return o != 0 && Py_TYPE(o) == &CursorType;
}

static Cursor* Cursor_Validate(PyObject* obj, DWORD flags)
Cursor* Cursor_Validate(PyObject* obj, DWORD flags)
{
// Validates that a PyObject is a Cursor (like Cursor_Check) and optionally some other requirements controlled by
// `flags`. If valid and all requirements (from the flags) are met, the cursor is returned, cast to Cursor*.
Expand Down Expand Up @@ -1349,7 +1343,6 @@ static PyObject* Cursor_fetchmany(PyObject* self, PyObject* args)
return result;
}


static char tables_doc[] =
"C.tables(table=None, catalog=None, schema=None, tableType=None) --> self\n"
"\n"
Expand Down Expand Up @@ -2396,6 +2389,7 @@ static PyMethodDef Cursor_methods[] =
{ "fetchone", (PyCFunction)Cursor_fetchone, METH_NOARGS, fetchone_doc },
{ "fetchall", (PyCFunction)Cursor_fetchall, METH_NOARGS, fetchall_doc },
{ "fetchmany", (PyCFunction)Cursor_fetchmany, METH_VARARGS, fetchmany_doc },
{ "fetchdictarray", (PyCFunction)Cursor_fetchdictarray, METH_VARARGS|METH_KEYWORDS, fetchdictarray_doc },
{ "nextset", (PyCFunction)Cursor_nextset, METH_NOARGS, nextset_doc },
{ "tables", (PyCFunction)Cursor_tables, METH_VARARGS|METH_KEYWORDS, tables_doc },
{ "columns", (PyCFunction)Cursor_columns, METH_VARARGS|METH_KEYWORDS, columns_doc },
Expand All @@ -2410,12 +2404,14 @@ static PyMethodDef Cursor_methods[] =
{ "skip", (PyCFunction)Cursor_skip, METH_VARARGS, skip_doc },
{ "commit", (PyCFunction)Cursor_commit, METH_NOARGS, commit_doc },
{ "rollback", (PyCFunction)Cursor_rollback, METH_NOARGS, rollback_doc },
{"cancel", (PyCFunction)Cursor_cancel, METH_NOARGS, cancel_doc},
{"__enter__", Cursor_enter, METH_NOARGS, enter_doc },
{"__exit__", Cursor_exit, METH_VARARGS, exit_doc },
{ "cancel", (PyCFunction)Cursor_cancel, METH_NOARGS, cancel_doc},
{ "__enter__", Cursor_enter, METH_NOARGS, enter_doc },
{ "__exit__", Cursor_exit, METH_VARARGS, exit_doc },
{0, 0, 0, 0}
};



static char cursor_doc[] =
"Cursor objects represent a database cursor, which is used to manage the context\n" \
"of a fetch operation. Cursors created from the same connection are not\n" \
Expand Down
9 changes: 9 additions & 0 deletions src/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#ifndef CURSOR_H
#define CURSOR_H

enum
{
CURSOR_REQUIRE_CNXN = 0x00000001,
CURSOR_REQUIRE_OPEN = 0x00000003, // includes _CNXN
CURSOR_REQUIRE_RESULTS = 0x00000007, // includes _OPEN
CURSOR_RAISE_ERROR = 0x00000010,
};

struct Connection;

struct ColumnInfo
Expand Down Expand Up @@ -160,5 +168,6 @@ void Cursor_init();

Cursor* Cursor_New(Connection* cnxn);
PyObject* Cursor_execute(PyObject* self, PyObject* args);
Cursor* Cursor_Validate(PyObject* obj, DWORD flags);

#endif
Loading