Skip to content

Commit

Permalink
removed comments from env.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nargis Sultani committed Nov 27, 2023
1 parent 31c8d1f commit 1a8bb3e
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions db_revisions/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,37 @@
fileConfig(config.config_file_name)


def run_migrations_offline():
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode. This generates the SQL script without executing on the database.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True, dialect_opts={"paramstyle": "named"}
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)

with context.begin_transaction():
context.run_migrations()


def run_migrations_online():
"""configuration = config.get_section(config.config_ini_section)
def run_migrations_online() -> None:
"""Run migrations in 'online' mode.
connectable = engine_from_config(
configuration,
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata, version_table_schema=target_metadata.schema
)
with context.begin_transaction():
context.run_migrations()"""
In this scenario we need to create an Engine
and associate a connection with the context.
"""

connectable = context.config.attributes.get("connection", None)

Expand Down

0 comments on commit 1a8bb3e

Please sign in to comment.