Running up/down-grades as a role #1067
-
I have a database in which I would like a NOLOGIN role to be the owner of everything and then allow other users to be members of that role for limited times. Example
How can I get alembic to log in as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
hey there - alembic and SQLAlchemy have no interaction with roles. the URL that you provide is how the driver connects, and from there, it just executes commands. so this would be a question of configuring your database to allow a login that comes in as what you need. on this end I dont even know what database this is, so if you happen to share that information, I can point you to the driver documentation where they might have advice on this. if the solution ends up that you need to execute a command after connecting, you can configure that in your env.py by running that command on the connection after you've created it, something like: with connectable.connect() as connection:
connection.exec_driver_sql("emit SQL to set up local role / login / etc here")
context.configure(
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations() |
Beta Was this translation helpful? Give feedback.
hey there -
alembic and SQLAlchemy have no interaction with roles. the URL that you provide is how the driver connects, and from there, it just executes commands. so this would be a question of configuring your database to allow a login that comes in as what you need. on this end I dont even know what database this is, so if you happen to share that information, I can point you to the driver documentation where they might have advice on this.
if the solution ends up that you need to execute a command after connecting, you can configure that in your env.py by running that command on the connection after you've created it, something like: