예제 #1
0
    def __init__(self, logger=None):
        super().__init__()
        self.settings = get_project_settings()

        self.engine = create_engine(mysql_connection_string())
        self.session = Session(self.engine)

        self.logger = logger or logging.getLogger(name=__name__)
예제 #2
0
    def _init(self):
        self.settings = get_project_settings()
        self.engine = create_engine(mysql_connection_string())
        self.session = Session(self.engine)

        if not getattr(self, "logger", None):
            self.logger = logging.getLogger(name=self.__class__.__name__)

        install_shutdown_handlers(self.signal_shutdown_handler, True)
예제 #3
0
 def __init__(self):
     self.engine = create_engine(mysql_connection_string())
     self.session = None
예제 #4
0
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
config.set_main_option("sqlalchemy.url", mysql_connection_string())


def run_migrations_offline():
    """Run migrations in 'offline' mode.

    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")