Skip to content
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
48 changes: 22 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,49 @@ on:
- master
jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-CU15-ubuntu-20.04
image: mcr.microsoft.com/mssql/server:2022-CU15-ubuntu-22.04
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: Abcd12345678
options: >-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P Abcd12345678 -Q 'select 1' -b -o /dev/null"
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P Abcd12345678 -Q 'SELECT 1' -b -o /dev/null"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
TEST_MSSQL_PASS: Abcd12345678
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
steps:
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
run: |
pip install -U pip poetry
poetry config virtualenvs.create false
- name: Install requirements
run: make deps
allow-prereleases: true
- name: Install ODBC driver
run: |
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list -o /etc/apt/sources.list.d/mssql-release.list
curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
ACCEPT_EULA=Y sudo apt-get install -y msodbcsql18
- name: Run ci
run: make ci
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
activate-environment: true
- name: Install requirements
run: make deps
- name: Check style
run: make check
- name: Run tests
run: make testall
- name: Upload Coverage
run: coveralls --service=github
run: uvx coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
Expand All @@ -62,8 +59,7 @@ jobs:
coveralls:
name: Finish Coveralls
needs: test
runs-on: ubuntu-latest
container: python:3-slim
runs-on: ubuntu-22.04
steps:
- name: Finished
run: |
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install and configure Poetry
- name: Install dependencies
run: |
pip install -U pip poetry
poetry config virtualenvs.create false
- name: Build dists
run: make build
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Pypi Publish
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ sqlite.db
# virtual envs
venv*/
virtualenv*/
.venv*/
30 changes: 18 additions & 12 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,29 @@ There are several ways to make a virtual environment.
If you like to use *virtualenv* please run::

$ cd asyncodbc
$ virtualenv --python=`which python3.5` venv
$ virtualenv --python=`which python3.13` venv

For standard python *venv*::

$ cd asyncodbc
$ python3.5 -m venv venv
$ python3.13 -m venv venv

For *virtualenvwrapper*::

$ cd asyncodbc
$ mkvirtualenv --python=`which python3.5` asyncodbc
$ mkvirtualenv --python=`which python3.13` asyncodbc

For *uv*::

$ cd asyncodbc
$ uv venv --python=3.13 --prompt=asyncodbc-py3.13

There are other tools like *pyvenv* but you know the rule of thumb
now: create a python3.5 virtual environment and activate it.
now: create a python3 virtual environment and activate it.

After that please install libraries required for development::

$ pip install -r requirements-dev.txt
$ pip install -r pyproject.toml --group dev --group test -e .

We also recommend to install *ipdb* but it's on your own::

Expand All @@ -93,16 +98,16 @@ Run asyncodbc test suite
After all the preconditions are met you can run tests typing the next
command::

$ make test
$ make ci

Or if you want to run only one particular test::

$ py.test tests/test_connection.py -k test_basic_cursor
$ pytest tests/test_connection.py -k test_basic_cursor

The command at first will run the static and style checkers (sorry, we don't
accept pull requests with `pep8` or `pyflakes` errors).

On `flake8` success the tests will be run.
On `ruff` success the tests will be run.

Please take a look on the produced output.

Expand All @@ -116,7 +121,7 @@ We are trying hard to have good test coverage; please don't make it worse.

Use::

$ make cov
$ make testall

to run test suite and collect coverage information. Once the command
has finished check your coverage at the file that appears in the last
Expand All @@ -133,10 +138,11 @@ We encourage documentation improvements.

Please before making a Pull Request about documentation changes run::

$ make doc
$ pip install --group docs
$ make docs

Once it finishes it will output the index html page
``open file:///.../asyncodbc/docs/_build/html/index.html``.
``open file:///.../asyncodbc/build/html/index.html``.

Go to the link and make sure your doc changes looks good.

Expand All @@ -147,5 +153,5 @@ After finishing all steps make a GitHub_ Pull Request, thanks.


.. _unixODBC: http://www.unixodbc.org/
.. _GitHub: https://github.com/aio-libs/asyncodbc
.. _GitHub: https://github.com/aio-libs/aioodbc
.. _docker: https://docs.docker.com/engine/installation/
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

43 changes: 26 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,52 @@ py_warn = PYTHONDEVMODE=1
pytest_opts = -n auto --cov=asyncodbc --tb=native -q

up:
@poetry update
@uv lock --upgrade

deps:
@poetry install
@uv sync --inexact --all-extras --all-groups --no-group docs $(options)

check: deps build
ifneq ($(shell which black),)
black --check $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
endif
pflake8 $(checkfiles)
_style:
@ruff format $(checkfiles)
@ruff check --fix $(checkfiles)
style: deps _style

_codeqc:
#mypy $(checkfiles)
#pylint -d C,W,R $(checkfiles)
#bandit -r $(checkfiles)
bandit -c pyproject.toml -r $(checkfiles)
twine check dist/*
codeqc: build _codeqc

_check: _build
@ruff format --check $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
@ruff check $(checkfiles)
$(MAKE) _codeqc
check: deps _check

_lint: _build _style _codeqc
lint: deps _lint

test_mssql: deps
test: deps test_mssql

test_mssql:
$(py_warn) TEST_DSN="DRIVER=ODBC Driver 18 for SQL Server;SERVER=127.0.0.1,1433;UID=sa;PWD=$(TEST_MSSQL_PASS);TrustServerCertificate=YES;MARS_Connection=YES" pytest $(pytest_opts)

_testall: test_mssql

testall: deps _testall
coverage report

ci: check testall
ci: check _testall

docs: deps
uv pip install --group docs
rm -fR ./build
sphinx-build -M html docs build

style: deps
isort -src $(checkfiles)
black $(checkfiles)

build: deps
_build:
rm -fR dist/
poetry build
uv build
build: deps _build

publish: deps build
twine upload dist/*
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
asyncodbc
=========
.. image:: https://travis-ci.com/tortoise/asyncodbc.svg?branch=master
.. image:: https://travis-ci.com/tortoise/asyncodbc.svg?branch=main
:target: https://travis-ci.com/tortoise/asyncodbc
.. image:: https://coveralls.io/repos/tortoise/asyncodbc/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/tortoise/asyncodbc?branch=master
.. image:: https://coveralls.io/repos/tortoise/asyncodbc/badge.svg?branch=main&service=github
:target: https://coveralls.io/github/tortoise/asyncodbc?branch=main
.. image:: https://img.shields.io/pypi/v/asyncodbc.svg
:target: https://pypi.python.org/pypi/asyncodbc

**asyncodbc** is a Python 3.5+ module that makes it possible to access ODBC_ databases
**asyncodbc** is a Python 3.9+ module that makes it possible to access ODBC_ databases
with asyncio_. It relies on the awesome pyodbc_ library and preserves the same look and
feel. *asyncodbc* was written using `async/await` syntax (PEP492_) and thus is not compatible
with Python versions older than 3.5. Internally *asyncodbc* employs threads to avoid
feel. *asyncodbc* was written using `async/await` syntax (PEP492_) and only support
Python that is not end-of-life(EOL). Internally *asyncodbc* employs threads to avoid
blocking the event loop, threads_ are not that as bad as you think!. Other
drivers like motor_ use the same approach.

Expand Down Expand Up @@ -137,7 +137,7 @@ Run tests
For testing purposes you need to install docker_ and the development
requirements::

$ pip install -r requirements-dev.txt
$ pip install -r pyproject.toml --group test -e .

In order to simplify development you should install the provided docker container.
This way you don't need to install any databases or other system libraries, everything happens inside the container.
Expand All @@ -150,31 +150,32 @@ Then just execute::
The test will automatically pull images and build containers with
the required databases.

*NOTE:* Running tests requires Python 3.6 or higher.
*NOTE:* Running tests requires Python 3.9 or higher.


Other SQL Drivers
-----------------

* aiopg_ - asyncio client for PostgreSQL
* asyncpg_ - asyncio client for PostgreSQL
* aiomysql_ - asyncio client form MySQL


Requirements
------------

* Python_ 3.5+
* Python_ 3.9+
* pyodbc_
* uvloop_ (optional)


.. _Python: https://www.python.org
.. _asyncio: http://docs.python.org/3.4/library/asyncio.html
.. _asyncio: http://docs.python.org/3.14/library/asyncio.html
.. _pyodbc: https://github.com/mkleehammer/pyodbc
.. _uvloop: https://github.com/MagicStack/uvloop
.. _ODBC: https://en.wikipedia.org/wiki/Open_Database_Connectivity
.. _aiopg: https://github.com/tortoise/aiopg
.. _aiomysql: https://github.com/tortoise/aiomysql
.. _asyncpg: https://github.com/MagicStack/asyncpg
.. _aiopg: https://github.com/aio-libs/aiopg
.. _aiomysql: https://github.com/aio-libs/aiomysql
.. _PEP492: https://www.python.org/dev/peps/pep-0492/
.. _unixODBC: http://www.unixodbc.org/
.. _threads: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/
Expand Down
Loading
Loading