-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add asyncmy
support
#7000
Add asyncmy
support
#7000
Conversation
Wonderful! |
can we have this set up in tox.ini / setup.cfg so that tests can be run against it? did you run the tests? |
can i please have commit access to your branch? |
sure |
it's still rejecting me. can you please apply this patch to your branch, we can then pull into jenkins and have the tests run commit dbd94944faad707dc78fa1628b74782ae6810454
Author: Mike Bayer <mike_mp@zzzcomputing.com>
Date: Mon Sep 13 13:37:17 2021 -0400
set up for tox
Change-Id: I7c6702e5998fba49be72d763c1be52edc60f2687
diff --git a/setup.cfg b/setup.cfg
index d88cb13d11..a55822286a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -74,6 +74,9 @@ pymysql =
aiomysql =
%(asyncio)s
aiomysql;python_version>="3"
+asyncmy =
+ %(asyncio)s
+ asyncmy;python_version>="3"
aiosqlite =
%(asyncio)s
aiosqlite;python_version>="3"
@@ -164,6 +167,8 @@ mysql = mysql://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4
pymysql = mysql+pymysql://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4
aiomysql = mysql+aiomysql://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4
aiomysql_fallback = mysql+aiomysql://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4&async_fallback=true
+asyncmy = mysql+asyncmy://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4
+asyncmy_fallback = mysql+asyncmy://scott:tiger@127.0.0.1:3306/test?charset=utf8mb4&async_fallback=true
mariadb = mariadb://scott:tiger@127.0.0.1:3306/test
mssql = mssql+pyodbc://scott:tiger^5HHH@mssql2017:1433/test?driver=ODBC+Driver+13+for+SQL+Server
mssql_pymssql = mssql+pymssql://scott:tiger@ms_2008
diff --git a/tox.ini b/tox.ini
index 3cf11ba2e7..42750f5d11 100644
--- a/tox.ini
+++ b/tox.ini
@@ -31,6 +31,7 @@ deps=
mysql: .[mysql]
mysql: .[pymysql]
mysql: git+https://github.com/sqlalchemy/aiomysql@sqlalchemy_tox; python_version >= '3'
+ mysql: .[asyncmy]; python_version >= '3'
mysql: .[mariadb_connector]; python_version >= '3'
oracle: .[oracle]
@@ -102,9 +103,9 @@ setenv=
py2{,7}-mysql: MYSQL={env:TOX_MYSQL_PY2K:{env:TOX_MYSQL:--db mysql}}
mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql}
- py3{,5,6,7,8,9}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver aiomysql}
+ py3{,5,6,7,8,9}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver aiomysql --dbdriver asyncmy}
# omit aiomysql for Python 3.10
- py3{,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector}
+ py3{,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver asyncmy}
mssql: MSSQL={env:TOX_MSSQL:--db mssql} |
I apply it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 398064b of this pull request into gerrit so we can run tests and reviews and stuff
New Gerrit review created for change 398064b: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3079 |
thank you |
pushing is not working, but we are just about done
apply this patch please, should fix the rest diff --git a/lib/sqlalchemy/dialects/mysql/asyncmy.py b/lib/sqlalchemy/dialects/mysql/asyncmy.py
index 657298cc7c..3dac325af6 100644
--- a/lib/sqlalchemy/dialects/mysql/asyncmy.py
+++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py
@@ -161,6 +161,7 @@ class AsyncAdapt_asyncmy_ss_cursor(AsyncAdapt_asyncmy_cursor):
def close(self):
if self._cursor is not None:
+ self.await_(self._cursor.fetchall())
self.await_(self._cursor.close())
self._cursor = None
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 9bf12e194c..c9c77c925c 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -2915,7 +2915,7 @@ class MySQLDialect(default.DefaultDialect):
"WHERE TABLE_TYPE='SEQUENCE' and TABLE_NAME=:name AND "
"TABLE_SCHEMA=:schema_name"
),
- dict(name=sequence_name, schema_name=schema),
+ dict(name=util.text_type(sequence_name), schema_name=util.text_type(schema)),
)
return cursor.first() is not None
|
done |
Is the bot not picking these up? I'll have to push manually |
i hope github didnt change the stupid API |
permissions issue of some kind Exception: Got response 403 for https://api.github.com/repos/sqlalchemy/sqlalchemy/collaborators/zzzeek/permission: b'{"message":"Must have push access to view collaborator permission.","documentation_url":"https://docs.github.com/rest/reference/repos#get-repository-permissions-for-a-user"}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision f7d6c81 of this pull request into gerrit so we can run tests and reviews and stuff
Patchset f7d6c81 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3079 |
oh hey, this is your DBAPI , great! I can get it all working but there is two areas that the driver doesnt handle well. One is that the connection raises AttributeError if you try to call it after it's closed, this should be InterfaceError: import asyncio
import asyncmy
async def main():
asyncmy_connection = await asyncmy.connect(user="scott", password="tiger", host="localhost", db="test")
# fine
await asyncmy_connection.ping(False)
asyncmy_connection.close()
# attribute error
await asyncmy_connection.ping(False)
asyncio.run(main()) output:
the other is that if you have an unconsumed server side cursor, you can't close the cursor or do anything like roll back the connection until the cursor is fully consumed, it should clean this up automatically: import asyncio
import asyncmy
async def main():
asyncmy_connection = await asyncmy.connect(user="scott", password="tiger", host="localhost", db="test")
ss_cursor = asyncmy_connection.cursor(asyncmy.cursors.SSCursor)
await ss_cursor.execute("select 1")
# uncomment to resolve
#await ss_cursor.fetchall()
# fails
await asyncmy_connection.rollback()
asyncio.run(main()) output:
the AttributeError is more important, I've worked around it for now. thanks for the contribution! I'm finishing this up now and obviously asyncmy moves to the top of the list of MySQL asyncio drivers. |
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3079 has been merged. Congratulations! :) |
Fixed that already and wait release |
If you could post here what version will fix there we may decide to set that one as the lowest supported. thanks for the contribution! |
@zzzeek do you think it would makes sense to set 0.2.0 as the lowest supported version? |
mike bayer (zzzeek) wrote:
looks like it's released, i dont think it makes that much difference but i want to do another gerrit run in any case lets see if i can remove my workarounds View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3079 |
mike bayer (zzzeek) wrote: looks like i can remove my cursor workarounds with 0.2.0 so i can gerrit that. however if it has a new error code for "this connection is closed" we'd need to code for that too when it comes out, separate issue (right now it raises AttributeError). View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3079 |
Description
Add
asyncmy
support, another asyncio driver for mysqlSee #6993
Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>
in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>
in the commit messageHave a nice day!