
from sqlalchemy import engine_from_config
import aybu.manager.models


def setup(env):
    settings = env['request'].registry.settings
    env['models'] = aybu.manager.models
    env['engine'] = engine_from_config(settings, 'sqlalchemy.')
    env['request'].set_db_engine = env['engine']
    aybu.core.models.Base.metadata.bind = env['engine']


from sqlalchemy import engine_from_config
import aybu.manager.models


def setup(env):
    settings = env['request'].registry.settings
    env['models'] = aybu.manager.models
    env['engine'] = engine_from_config(settings, 'sqlalchemy.')
    env['request'].set_db_engine = env['engine']
    aybu.manager.models.Base.metadata.bind = env['engine']
    aybu.manager.models.Environment.initialize(settings)
    env['session'] = env['request'].db_session


Initialize session and environment in shell
Initialize session and environment in shell

  
  from sqlalchemy import engine_from_config
  import aybu.manager.models
  
  
  def setup(env):
      settings = env['request'].registry.settings
      env['models'] = aybu.manager.models
      env['engine'] = engine_from_config(settings, 'sqlalchemy.')
      env['request'].set_db_engine = env['engine']
-     aybu.core.models.Base.metadata.bind = env['engine']
+     aybu.manager.models.Base.metadata.bind = env['engine']
+     aybu.manager.models.Environment.initialize(settings)
+     env['session'] = env['request'].db_session
  
+ 
Initialize session and environment in shell
## Code Before:

from sqlalchemy import engine_from_config
import aybu.manager.models


def setup(env):
    settings = env['request'].registry.settings
    env['models'] = aybu.manager.models
    env['engine'] = engine_from_config(settings, 'sqlalchemy.')
    env['request'].set_db_engine = env['engine']
    aybu.core.models.Base.metadata.bind = env['engine']

## Instruction:
Initialize session and environment in shell
## Code After:

from sqlalchemy import engine_from_config
import aybu.manager.models


def setup(env):
    settings = env['request'].registry.settings
    env['models'] = aybu.manager.models
    env['engine'] = engine_from_config(settings, 'sqlalchemy.')
    env['request'].set_db_engine = env['engine']
    aybu.manager.models.Base.metadata.bind = env['engine']
    aybu.manager.models.Environment.initialize(settings)
    env['session'] = env['request'].db_session

