Revision 44d80edf snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/env.py

b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/env.py
2 2
from alembic import context
3 3
from sqlalchemy import engine_from_config, pool
4 4
from logging.config import fileConfig
5
from synnefo.settings import PITHOS_BACKEND_DB_CONNECTION
5 6

  
6 7
# this is the Alembic Config object, which provides
7 8
# access to the values within the .ini file in use.
8 9
config = context.config
9 10

  
10
# Interpret the config file for Python logging. 
11
# Interpret the config file for Python logging.
11 12
# This line sets up loggers basically.
12 13
fileConfig(config.config_file_name)
13 14

  
......
22 23
# my_important_option = config.get_main_option("my_important_option")
23 24
# ... etc.
24 25

  
26
db = config.get_main_option("sqlalchemy.url", PITHOS_BACKEND_DB_CONNECTION)
27
config.set_main_option("sqlalchemy.url", db)
28

  
25 29
def run_migrations_offline():
26 30
    """Run migrations in 'offline' mode.
27 31

  
......
29 33
    and not an Engine, though an Engine is acceptable
30 34
    here as well.  By skipping the Engine creation
31 35
    we don't even need a DBAPI to be available.
32
    
36

  
33 37
    Calls to context.execute() here emit the given string to the
34 38
    script output.
35
    
39

  
36 40
    """
37 41
    url = config.get_main_option("sqlalchemy.url")
38 42
    context.configure(url=url)
......
45 49

  
46 50
    In this scenario we need to create an Engine
47 51
    and associate a connection with the context.
48
    
52

  
49 53
    """
50 54
    engine = engine_from_config(
51
                config.get_section(config.config_ini_section), 
52
                prefix='sqlalchemy.', 
55
                config.get_section(config.config_ini_section),
56
                prefix='sqlalchemy.',
53 57
                poolclass=pool.NullPool)
54 58

  
55 59
    connection = engine.connect()
56 60
    context.configure(
57
                connection=connection, 
61
                connection=connection,
58 62
                target_metadata=target_metadata
59 63
                )
60 64

  

Also available in: Unified diff