Hi, I'm trying to move from 1.3 to 1.4 and immediately hit the issue with
sqlalchemy.interfaces being removed.
Basically, we have a wrapper around create_engine() that looks something
like this:
*from sqlalchemy.engine import create_engine as _create_enginefrom
sqlalchemy.engine.interfaces import PoolListenerclass
StrictPoolListener(PoolListener): def connect(self, dbapi_connection,
connection_record): cursor = dbapi_connection.cursor()
cursor.execute("SET sql_mode='TRADITIONAL'")def create_engine(database_url,
**kwargs): if kwargs: engine = _create_engine(database_url,
**kwargs) else: engine = _create_engine(database_url,
pool_pre_ping=True,
pool_recycle=3600,
listeners=[StrictPoolListener()]) return engine*
Which now fails. It sounds like with 1.4 (and before) we could use
something like this:
https://docs.sqlalchemy.org/en/14/dialects/mysql.html#changing-the-sql-mode
*from sqlalchemy import create_engine, eventeng =
create_engine("mysql://scott:tiger@localhost/test",
echo='debug')@event.listens_for(eng, "connect", insert=True)def
connect(dbapi_connection, connection_record): cursor =
dbapi_connection.cursor() cursor.execute("SET sql_mode =
'STRICT_ALL_TABLES'")*
Maybe I'm missing something, but I don't see how that's going to work.
"eng" would need to be defined and in scope before I could set a listener
on it. With our existing code, someone gets back an engine object that
automatically sets the correct sql_mode.
Is there any workaround that lets us continue to use the first pattern?
Thanks.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/0871c81f-a8da-492d-b478-6fb2e7fcd641n%40googlegroups.com.