How to set target_metadata programatically?

24 views
Skip to first unread message

Nikola Radovanovic

unread,
Jan 4, 2021, 6:27:44 AMJan 4
to alembic-discussion
Hi,
I would like to create set of thin wrappers on top of the alembic since we need some customization. So first thing for me to solve is how to set target_metadata programatically. What I realized by reading documentation and code is that I need something like:

alembic_cfg = Config("alembic.ini")
alembic_cfg.set_main_option("sqlalchemy.url", "postgres://user:pass@localhost/testdb")
script = ScriptDirectory.from_config(alembic_cfg)

engine = create_engine(config.db_uri)
with engine.connect() as connection:
    env_ctx = EnvironmentContext(config=alembic_cfg, script=script)
    env_ctx.configure(connection=connection, target_metadata=Base.metadata)
    ctx = env_ctx.get_context()

Next, I want to call revision with autogenerate set to True, but I am not sure how?

Thank you in advance.

Kindest regards

Lucas Miller

unread,
Jan 4, 2021, 11:55:49 AMJan 4
to alembic-d...@googlegroups.com
Wrong project, please try:
https://www.sqlalchemy.org/develop.html

Have a nice day,

Lucas
> --
> You received this message because you are subscribed to the Google Groups "alembic-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discuss...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/alembic-discussion/adb7d92c-bfb8-4b4d-abf5-ddf48a50f3ccn%40googlegroups.com.

Nikola Radovanovic

unread,
Jan 5, 2021, 10:56:08 AMJan 5
to alembic-discussion
OK,
I will but tbf everything I wanted to know is how to use/customize Alembic API.

Kindest regards

Sybren A. Stüvel

unread,
Jan 5, 2021, 12:44:37 PMJan 5
to alembic-d...@googlegroups.com

There are two projects, both named Alembic. The one you know deals with databases. The one you're mailing to deals with the exchange of 3D models & animation in digital film productions. Really, this list can't help you beyond the info you've already gotten.

Sybren

Nikola Radovanovic

unread,
Jan 5, 2021, 4:11:44 PMJan 5
to alembic-d...@googlegroups.com
Ah sorry, did not realize that.

Kindest regards

Reply all
Reply to author
Forward
0 new messages