Skip to content

Commit

Permalink
Merge commit '0a8af2355562ea961477738d66b3334332447186'
Browse files Browse the repository at this point in the history
* commit '0a8af2355562ea961477738d66b3334332447186':
  Bump version and tweak setup.py (aio-libs#540)
  Fill changelog for 0.0.21 release (aio-libs#538)
  Support python 3.7 and 3.8 in tests and travis CI
  Update dependencies (aio-libs#485)
  chore(flake8): fixed flake8 errors (aio-libs#484)
  added support for sqlalchemy default parameters aio-libs#455 (aio-libs#456)
  Fix flake
  Fixed invalid datatime for MySQL 5.7
  Rewrote tests to use pytest exclusively
  Fixed linting
  Attempted to move db completely to docker
  Fix Travis attempt 1
  Fix aio-libs#454
  • Loading branch information
andr-04 committed May 18, 2021
2 parents 31ecda6 + 0a8af23 commit d6d9b51
Show file tree
Hide file tree
Showing 28 changed files with 2,795 additions and 2,714 deletions.
39 changes: 23 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: python

python:
- 3.5.3
- 3.6
- 3.7
- 3.8

env:
matrix:
Expand All @@ -15,27 +16,33 @@ services:
matrix:
include:
- python: 3.6
env: PYTHONASYNCIODEBUG=
addons:
mariadb: 5.5
env:
- PYTHONASYNCIODEBUG=
- DB=mariadb
- DBTAG=5.5
- python: 3.6
env: PYTHONASYNCIODEBUG=1
env:
- PYTHONASYNCIODEBUG=1
- DB=mariadb
- DBTAG=10.0
addons:
mariadb: 10.0
mariadb: '10.0'
- python: 3.6
env: PYTHONASYNCIODEBUG=
addons:
mariadb: 10.1
env:
- PYTHONASYNCIODEBUG=
- DB=mariadb
- DBTAG=10.5
- python: 3.6
env: PYTHONASYNCIODEBUG=
addons:
mysql: 5.7
env:
- PYTHONASYNCIODEBUG=
- DB=mysql
- DBTAG=5.7


before_script:
- "mysql -e 'SELECT VERSION()'"
- "mysql -e 'DROP DATABASE IF EXISTS test_pymysql; create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
- "mysql -e 'DROP DATABASE IF EXISTS test_pymysql2; create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
#before_script:
# - "mysql -e 'SELECT VERSION()'"
# - "mysql -e 'DROP DATABASE IF EXISTS test_pymysql; create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
# - "mysql -e 'DROP DATABASE IF EXISTS test_pymysql2; create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"

install:
- pip install -Ur requirements-dev.txt
Expand Down
22 changes: 22 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Changes
-------

0.0.21 (2020-11-26)
^^^^^^^^^^^^^^^^^^^

* Allow to use custom Cursor subclasses #374

* Fill Connection class with actual client version #388

* Fix legacy __aiter__ methods #403

* Fix & update docs #418 #437

* Ignore pyenv's .python-version file #424

* Replace asyncio.streams.IncompleteReadError with asyncio.IncompleteReadError #460 #454

* Add support for SQLAlchemy default parameters #455 #466

* Update dependencies #485

* Support Python 3.7 & 3.8 #493


0.0.20 (2018-12-19)
^^^^^^^^^^^^^^^^^^^

Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

FLAGS=

checkrst:
python setup.py check --restructuredtext

flake:
pyroma:
pyroma -d .


flake:checkrst pyroma
flake8 aiomysql tests examples

test: flake
Expand All @@ -12,6 +18,7 @@ test: flake
vtest:
py.test -s -v $(FLAGS) ./tests/


cov cover coverage: flake
py.test -s -v --cov-report term --cov-report html --cov aiomysql ./tests
@echo "open file://`pwd`/htmlcov/index.html"
Expand Down
2 changes: 1 addition & 1 deletion aiomysql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .cursors import Cursor, SSCursor, DictCursor, SSDictCursor
from .pool import create_pool, Pool

__version__ = '0.0.20'
__version__ = '0.0.21'

__all__ = [

Expand Down
2 changes: 1 addition & 1 deletion aiomysql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ async def _read_packet(self, packet_type=MysqlPacket):
async def _read_bytes(self, num_bytes):
try:
data = await self._reader.readexactly(num_bytes)
except asyncio.streams.IncompleteReadError as e:
except asyncio.IncompleteReadError as e:
msg = "Lost connection to MySQL server during query"
raise OperationalError(2013, msg) from e
except (IOError, OSError) as e:
Expand Down
2 changes: 1 addition & 1 deletion aiomysql/sa/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def execute(self, query, *multiparams, **params):
)
In the case that a plain SQL string is passed, a tuple or
individual values in \*multiparams may be passed::
individual values in *multiparams may be passed::
await conn.execute(
"INSERT INTO table (id, value) VALUES (%d, %s)",
Expand Down
18 changes: 18 additions & 0 deletions aiomysql/sa/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,29 @@

try:
from sqlalchemy.dialects.mysql.pymysql import MySQLDialect_pymysql
from sqlalchemy.dialects.mysql.mysqldb import MySQLCompiler_mysqldb
except ImportError: # pragma: no cover
raise ImportError('aiomysql.sa requires sqlalchemy')


class MySQLCompiler_pymysql(MySQLCompiler_mysqldb):
def construct_params(self, params=None, _group_number=None, _check=True):
pd = super().construct_params(params, _group_number, _check)

for column in self.prefetch:
pd[column.key] = self._exec_default(column.default)

return pd

def _exec_default(self, default):
if default.is_callable:
return default.arg(self.dialect)
else:
return default.arg


_dialect = MySQLDialect_pymysql(paramstyle='pyformat')
_dialect.statement_compiler = MySQLCompiler_pymysql
_dialect.default_paramstyle = 'pyformat'


Expand Down
11 changes: 8 additions & 3 deletions examples/example_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

@asyncio.coroutine
def test_example():
conn = yield from aiomysql.connect(host='127.0.0.1', port=3306,
user='root', password='', db='mysql',
loop=loop)
conn = yield from aiomysql.connect(
host='127.0.0.1',
port=3306,
user='root',
password='',
db='mysql',
loop=loop
)

cur = yield from conn.cursor()
yield from cur.execute("SELECT Host,User FROM user")
Expand Down
27 changes: 16 additions & 11 deletions examples/example_pool_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@

@asyncio.coroutine
def test_example():
pool = yield from aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='',
db='mysql', loop=loop)
with (yield from pool) as conn:
cur = yield from conn.cursor()
yield from cur.execute("SELECT 10")
# print(cur.description)
(r,) = yield from cur.fetchone()
assert r == 10
pool.close()
yield from pool.wait_closed()
pool = yield from aiomysql.create_pool(
host='127.0.0.1',
port=3306,
user='root',
password='',
db='mysql',
loop=loop
)
with (yield from pool) as conn:
cur = yield from conn.cursor()
yield from cur.execute("SELECT 10")
# print(cur.description)
(r,) = yield from cur.fetchone()
assert r == 10
pool.close()
yield from pool.wait_closed()


loop.run_until_complete(test_example())
25 changes: 13 additions & 12 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
coverage==4.5.1
flake8==3.5.0
ipdb==0.11
ipython==7.0.1
pytest==3.9.1
pytest-cov==2.6.0
pytest-sugar==0.9.1
PyMySQL>=0.9,<=0.9.2
docker==3.5.1
sphinx==1.8.1
coverage>=4.5.1,<=5.1
flake8>=3.5.0,<=3.7.9
ipdb>=0.11,<=0.13.2
ipython>=7.0.1,<=7.13.0
pytest>=3.9.1,<=5.4.1
pytest-cov>=2.6.0,<=2.8.1
pytest-sugar>=0.9.1,<=0.9.3
PyMySQL>=0.9,<=0.9.3
docker>=3.5.1,<=4.2.0
sphinx>=1.8.1, <=3.0.3
sphinxcontrib-asyncio==0.2.0
sqlalchemy==1.2.12
uvloop==0.11.2; python_version >= '3.5'
sqlalchemy>1.2.12,<=1.3.16
uvloop>=0.11.2,<=0.14.0; python_version >= '3.5'
pyroma==2.6
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup, find_packages


install_requires = ['PyMySQL>=0.9,<=0.9.2']
install_requires = ['PyMySQL>=0.9,<=0.9.3']

PY_VER = sys.version_info

Expand Down Expand Up @@ -47,6 +47,8 @@ def read_version():
'Framework :: AsyncIO',
]

keywords = ["mysql", "asyncio", "aiomysql"]


setup(name='aiomysql',
version=read_version(),
Expand All @@ -62,4 +64,5 @@ def read_version():
packages=find_packages(exclude=['tests', 'tests.*']),
install_requires=install_requires,
extras_require=extras_require,
keywords=keywords,
include_package_data=True)

0 comments on commit d6d9b51

Please sign in to comment.