'Initialize SQLAlchemy'

def init_sqlalchemy(self):

    try:
        if ([int(part) for part in sqlalchemy.__version__.split(u'.')] < [0, 7, 0]):
            print(u'FATAL:    SQLAlchemy    0.7.0    or    newer    required.    Please    upgrade    your    SQLAlchemy.', file=sys.stderr)
            sys.exit(1)
    except ValueError as e:
        log.critical(u'Failed    to    check    SQLAlchemy    version,    you    may    need    to    upgrade    it')
    if (self.database_uri is None):
        filename = self.db_filename.replace(u'\\', u'\\\\')
        self.database_uri = (u'sqlite:///%s' % filename)
    if (self.db_filename and (not os.path.exists(self.db_filename))):
        log.verbose((u'Creating    new    database    %s    -    DO    NOT    INTERUPT    ...' % self.db_filename))
    log.debug((u'Connecting    to:    %s' % self.database_uri))
    try:
        self.engine = sqlalchemy.create_engine(self.database_uri, echo=self.options.debug_sql, connect_args={u'check_same_thread': False, u'timeout': 10})
    except ImportError as e:
        print((u"FATAL:    Unable    to    use    SQLite.    Are    you    running    Python    2.7,    3.3    or    newer    ?\nPython    should    normally    have    SQLite    support    built    in.\nIf    you're    running    correct    version    of    Python    then    it    is    not    equipped    with    SQLite.\nYou    can    try    installing    `pysqlite`.    If    you    have    compiled    python    yourself,    recompile    it    with    SQLite    support.\nError:    %s" % e), file=sys.stderr)
        sys.exit(1)
    Session.configure(bind=self.engine)
    try:
        Base.metadata.create_all(bind=self.engine)
    except OperationalError as e:
        if os.path.exists(self.db_filename):
            print((u'%s    -    make    sure    you    have    write    permissions    to    file    %s' % (e.message, self.db_filename)), file=sys.stderr)
        else:
            print((u'%s    -    make    sure    you    have    write    permissions    to    directory    %s' % (e.message, self.config_base)), file=sys.stderr)
        raise
