diff --git a/.isort.cfg b/.isort.cfg index 7cd5b89c4..da74cdb60 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,5 +1,5 @@ [settings] line_length=100 multi_line_output=0 -known_third_party= +known_third_party=aiosqlite,ciso8601 not_skip=__init__.py diff --git a/requirements-dev.txt b/requirements-dev.txt index dbe0583c6..4d54b369e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,8 +7,8 @@ aenum==2.0.8 # via pypika aiocontextvars==0.1.2 ; python_version < "3.7" aiomysql==0.0.19 -aiosqlite==0.6.0 -alabaster==0.7.11 # via sphinx +aiosqlite==0.7.0 +alabaster==0.7.12 # via sphinx asn1crypto==0.24.0 # via cryptography astroid==2.0.4 # via pylint asyncpg==0.17.0 @@ -18,20 +18,21 @@ bandit==1.5.1 certifi==2018.8.24 # via requests cffi==1.11.5 # via cryptography chardet==3.0.4 # via requests -ciso8601==2.0.1 +ciso8601==2.1.1 click==7.0 # via pip-tools cloud-sptheme==1.9.4 -colorama==0.3.9 # via green +colorama==0.4.0 # via green coverage==4.5.1 # via coveralls, green -coveralls==1.5.0 +coveralls==1.5.1 cryptography==2.3.1 # via pymysql docopt==0.6.2 # via coveralls docutils==0.14 +filelock==3.0.9 # via tox flake8-isort==2.5 flake8==3.5.0 # via flake8-isort -gitdb2==2.0.4 # via gitpython +gitdb2==2.0.5 # via gitpython gitpython==2.1.11 # via bandit -green==2.12.1 +green==2.13.0 idna==2.7 # via cryptography, requests imagesize==1.1.0 # via sphinx isort==4.3.4 # via flake8-isort, pylint @@ -42,23 +43,23 @@ mccabe==0.6.1 # via flake8, pylint mypy-extensions==0.4.1 # via mypy mypy==0.630 packaging==18.0 # via sphinx -pbr==4.2.0 # via stevedore -pip-tools==3.0.0 +pbr==4.3.0 # via stevedore +pip-tools==3.1.0 pluggy==0.7.1 # via tox -py==1.6.0 # via tox +py==1.7.0 # via tox pycodestyle==2.3.1 # via flake8 pycparser==2.19 # via cffi pyflakes==1.6.0 # via flake8 pygments==2.2.0 pylint==2.1.1 pymysql==0.9.2 # via aiomysql -pyparsing==2.2.1 # via packaging -pypika==0.15.6 +pyparsing==2.2.2 # via packaging +pypika==0.15.7 pytz==2018.5 # via babel pyyaml==3.13 # via bandit requests==2.19.1 # via coveralls, sphinx six==1.11.0 # via astroid, bandit, cryptography, packaging, pip-tools, sphinx, stevedore, tox -smmap2==2.0.4 # via gitdb2 +smmap2==2.0.5 # via gitdb2 snowballstemmer==1.2.1 # via sphinx sphinx-autodoc-typehints==1.3.0 sphinx==1.8.1 @@ -66,8 +67,8 @@ sphinxcontrib-websupport==1.1.0 # via sphinx stevedore==1.29.0 # via bandit termstyle==0.1.11 # via green testfixtures==6.3.0 # via flake8-isort -toml==0.9.6 # via tox -tox==3.4.0 +toml==0.10.0 # via tox +tox==3.5.2 typed-ast==1.1.0 # via astroid, mypy unidecode==1.0.22 # via green urllib3==1.23 # via requests diff --git a/requirements.txt b/requirements.txt index fe4ad85eb..3a87367cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ pypika>=0.15.6,<1.0 ciso8601>=2.0 aiocontextvars==0.1.2;python_version<"3.7" -aiosqlite>=0.6.0 +aiosqlite>=0.7.0 diff --git a/tortoise/backends/sqlite/client.py b/tortoise/backends/sqlite/client.py index c967b9d58..caa2ff25c 100644 --- a/tortoise/backends/sqlite/client.py +++ b/tortoise/backends/sqlite/client.py @@ -70,16 +70,13 @@ def _in_transaction(self) -> 'TransactionWrapper': async def execute_insert(self, query: str, values: list) -> int: self.log.debug('%s: %s', query, values) async with self.acquire_connection() as connection: - cursor = await connection.execute(query, values) - await cursor.execute('SELECT last_insert_rowid()') - return (await cursor.fetchone())[0] + return (await connection.execute_insert(query, values))[0] @translate_exceptions async def execute_query(self, query: str) -> List[dict]: self.log.debug(query) async with self.acquire_connection() as connection: - cursor = await connection.execute(query) - return [dict(row) for row in await cursor.fetchall()] + return [dict(row) for row in await connection.execute_fetchall(query)] @translate_exceptions async def execute_script(self, query: str) -> None: diff --git a/tortoise/fields.py b/tortoise/fields.py index 55067bb2a..324978ebf 100644 --- a/tortoise/fields.py +++ b/tortoise/fields.py @@ -4,9 +4,9 @@ from decimal import Decimal from typing import Any, Optional +import ciso8601 from pypika import Table -import ciso8601 from tortoise.exceptions import ConfigurationError, NoValuesFetched, OperationalError from tortoise.utils import QueryAsyncIterator