Alembic list of known _impls - How to add a third-party one?

23 views
Skip to first unread message

gordon.d...@gmail.com

unread,
Jun 22, 2021, 8:57:55 AM6/22/21
to sqlalchemy-devel
As Alembic is preparing to "do stuff" it does a lookup by dialect name in  get_by_dialect()


While trying to run the Alembic suite with some third-party dialects (e.g. sybase) that lookup fails because the `_impls` dict only contains entries for "default" and the internal dialects (mssql, mysql, mariadb, oracle, postgresql, and sqlite). How would a third-party dialect inject itself into that dict?

Mike Bayer

unread,
Jun 22, 2021, 11:34:41 AM6/22/21
to sqlalche...@googlegroups.com


third party dialects currently inject by subclassing the default impl class.  if you have a third party test suite you'd probably need to make sure the import happens in conftest.py or in something that conftest.py calls upon (how are you running the CDB tests now?).     that said, we should also implement an entrypoint based system for 3rd party dialects and i think there is a github issue for this somewhere (maybe).
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-dev...@googlegroups.com.

gordon.d...@gmail.com

unread,
Jun 22, 2021, 1:09:33 PM6/22/21
to sqlalchemy-devel
I got lucky with CrDB; it "just worked". I looked for what they might have done and I didn't see anything, but now that I look again, of course, there it is:

jona...@findmeon.com

unread,
Jun 22, 2021, 2:25:21 PM6/22/21
to sqlalchemy-devel
IIRC, the registration is handled by class hierarchy and __init__.  see https://github.com/sqlalchemy/alembic/blob/b1e5a23c0f53482dd06b013ce8a9453dd0e5eb5d/alembic/ddl/impl.py#L16-L41

All the dialects inherit from class impl.DefaultImpl , which I believe does the registration through metaclasses

fwiw, i like the explicit registration that dogpile.cache does

Reply all
Reply to author
Forward
0 new messages