This looks like some kind of import issue or something you’re doing is 
interfering with the alembic.context module.

Another issue is that your stack trace seems to begin with running the 
“alembic” command;  the example in the documentation refers to API use of 
Alembic, not using the command line script.

Here’s how that section is used.  Create this script, “test.py":

    # inside of a "create the database" script, first create
    # tables:
    from sqlalchemy import create_engine, MetaData, Table, Column, Integer

    my_metadata = MetaData()
    Table('t', my_metadata, Column('x', Integer))
    engine = create_engine("sqlite:///mydb.db", echo=True)

    my_metadata.create_all(engine)

    # then, load the Alembic configuration and generate the
    # version table, "stamping" it with the most recent rev:
    from alembic.config import Config
    from alembic import command
    alembic_cfg = Config("./alembic.ini")
    command.stamp(alembic_cfg, "head")

run it:

        $ python test.py
        2014-10-21 14:47:30,868 INFO sqlalchemy.engine.base.Engine SELECT 
CAST('test plain returns' AS VARCHAR(60)) AS anon_1
        2014-10-21 14:47:30,868 INFO sqlalchemy.engine.base.Engine ()
        2014-10-21 14:47:30,868 INFO sqlalchemy.engine.base.Engine SELECT 
CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
        2014-10-21 14:47:30,869 INFO sqlalchemy.engine.base.Engine ()
        2014-10-21 14:47:30,869 INFO sqlalchemy.engine.base.Engine PRAGMA 
table_info("t")
        2014-10-21 14:47:30,869 INFO sqlalchemy.engine.base.Engine ()
        2014-10-21 14:47:30,870 INFO sqlalchemy.engine.base.Engine 
        CREATE TABLE t (
                x INTEGER
        )


        2014-10-21 14:47:30,870 INFO sqlalchemy.engine.base.Engine ()
        2014-10-21 14:47:30,871 INFO sqlalchemy.engine.base.Engine COMMIT
        INFO  [alembic.migration] Context impl SQLiteImpl.
        INFO  [alembic.migration] Will assume non-transactional DDL.

that’s how the code in that section is invoked.






> On Oct 21, 2014, at 9:14 AM, Bryan Hanson <hans...@gmail.com> wrote:
> 
> While following the tutorial section about building from scratch I get this 
> error:
> 
> Traceback (most recent call last):
>   File "/home/ubuntu/workspace/Envs/ScrapyProj/bin/alembic", line 9, in 
> <module>
>     load_entry_point('alembic==0.6.7', 'console_scripts', 'alembic')()
>   File 
> "/home/ubuntu/workspace/Envs/ScrapyProj/local/lib/python2.7/site-packages/alembic/config.py",
>  line 306, in main
>     CommandLine(prog=prog).main(argv=argv)
>   File 
> "/home/ubuntu/workspace/Envs/ScrapyProj/local/lib/python2.7/site-packages/alembic/config.py",
>  line 300, in main
>     self.run_cmd(cfg, options)
>   File 
> "/home/ubuntu/workspace/Envs/ScrapyProj/local/lib/python2.7/site-packages/alembic/config.py",
>  line 286, in run_cmd
>     **dict((k, getattr(options, k)) for k in kwarg)
>   File 
> "/home/ubuntu/workspace/Envs/ScrapyProj/local/lib/python2.7/site-packages/alembic/command.py",
>  line 129, in upgrade
>     script.run_env()
>   File 
> "/home/ubuntu/workspace/Envs/ScrapyProj/local/lib/python2.7/site-packages/alembic/environment.py",
>  line 105, in __exit__
>     context._remove_proxy()
>   File 
> "/home/ubuntu/workspace/Envs/ScrapyProj/local/lib/python2.7/site-packages/alembic/util.py",
>  line 84, in _remove_proxy
>     del globals_[name]
> KeyError: 'config'
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy-alembic+unsubscr...@googlegroups.com 
> <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to