Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify certain database in command-line #120

Closed
sqlalchemy-bot opened this issue Apr 23, 2013 · 5 comments
Closed

specify certain database in command-line #120

sqlalchemy-bot opened this issue Apr 23, 2013 · 5 comments

Comments

@sqlalchemy-bot
Copy link

@sqlalchemy-bot sqlalchemy-bot commented Apr 23, 2013

Migrated issue, originally created by holsety huang (@holsety)

I want something like:

alembic -d mysql://user:password@localhost/database upgrade head

specify the database in config file is not so convenient.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Apr 25, 2013

Michael Bayer (@zzzeek) wrote:

because alembic has no notion of a single database URL, it can't be a fixed argument like that. the best approach would be an option like -x "opt=value" which allows arbitrary configuration options to be added to the command line.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Jun 7, 2013

Michael Bayer (@zzzeek) wrote:

amazingly, I added this feature the other day in response to a totally different issue, and I named it "-x" just like I proposed here.

So with 0.6.0 you'd say:

alembic -x dbname=mysql://user:pw@host/db upgrade head

then in your env.py:

    cmd_line_url = context.get_x_argument(as_dictionary=True).get('dbname])
    if cmd_line_url:
        engine = create_engine(cmd_line_url)
    else:
        engine = engine_from_config(
                config.get_section(config.config_ini_section),
                prefix='sqlalchemy.',
                poolclass=pool.NullPool)

    connection = engine.connect()

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Jun 7, 2013

Changes by Michael Bayer (@zzzeek):

  • added labels: command interface
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Jun 7, 2013

Michael Bayer (@zzzeek) wrote:

I've added the above example to the 0.6.0 documentation (and also gave it a quick test).

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Jun 7, 2013

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant