I am trying to set up Alembic to work with Google Cloud Spanner, but no matter what I try I end up with one of the following errors when attempting to run a simple "alembic upgrade head
":
- sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:spanner
- KeyError: 'spanner+spanner'
I have tried so far:
In alembic.ini for sqlalchemy.url:
spanner:///projects/<project>/instances/<instance>/databases/<db>
spanner+spanner:///projects/<project>/instances/<instance>/databases/<db>
In env.py:
config.set_main_option("sqlalchemy.url", "spanner:///projects/<project>/instances/<instance>/databases/<db>")
config.set_main_option("sqlalchemy.url",
"spanner+spanner:///projects/<project>/instances/<instance>/databases/<db>")
I have tried with latest versions of SqlAlchemy/Alembic/SqlAlchemy-Spanner, as well as earlier versions (sqlalchemy 1.3 and matching versions of the others)
I have tried using sqlalchemy-spanner from PyPi and from GitHub (git+https://github.com/googleapis/python-spanner-sqlalchemy.git@v1.2.0#egg=sqlalchemy-spanner)
There is no code being executed so far, just trying to get Alembic to be able to connect to the instance. I have all required permissions (project owner).
From what I can see, it appears that the spanner dialect for SqlAlchemy isn't installed properly. I have tried to start a new project from scratch to elimiate old installations messing with my setup but no luck.
I've even tried to register the dialect manually through env.py with:
registry.register("spanner.spanner", "google.cloud.sqlalchemy_spanner", "SpannerDialect")
I'm by no means a Python expert (worked with Python for one year now after doing .Net/c# for 10 years), but I'm running out of ideas here. Any help would be highly appreciated.