Пример #1
0
    def cmd_geoip(options):
        from tranny.service import geoip
        from tranny.app import Session
        from tranny.app import config

        engine = create_engine(config.get_db_uri())
        Session.configure(bind=engine)
        Base.metadata.create_all(bind=engine)

        db_file_path = geoip.fetch_update(download=options.nodownload)
        geoip.update(Session(), db_file_path)
Пример #2
0
    def cmd_geoip(options):
        from tranny.service import geoip
        from tranny.app import Session
        from tranny.app import config

        engine = create_engine(config.get_db_uri())
        Session.configure(bind=engine)
        Base.metadata.create_all(bind=engine)

        db_file_path = geoip.fetch_update(download=options.nodownload)
        geoip.update(Session(), db_file_path)
Пример #3
0
def db_init(username="******", password="******", wipe=False):
    from tranny.app import Base, engine, Session
    Session.configure(bind=engine)
    try:
        if wipe:
            db_drop()
        Base.metadata.create_all(bind=engine)
    except DBAPIError:
        log.exception("Failed to initialize db schema")
    else:
        log.info("Initialized db schema successfully")
        session = Session()
        try:
            admin = User(user_name=username, password=password, role=constants.ROLE_ADMIN)
            session.add(admin)
            session.commit()
        except DBAPIError:
            session.rollback()
        else:
            log.info("Created admin user successfully")
            return True
    return False
Пример #4
0
def db_init(username="******", password="******", wipe=False):
    from tranny.app import Base, engine, Session
    Session.configure(bind=engine)
    try:
        if wipe:
            db_drop()
        Base.metadata.create_all(bind=engine)
    except DBAPIError:
        log.exception("Failed to initialize db schema")
    else:
        log.info("Initialized db schema successfully")
        session = Session()
        try:
            admin = User(user_name=username,
                         password=password,
                         role=constants.ROLE_ADMIN)
            session.add(admin)
            session.commit()
        except DBAPIError:
            session.rollback()
        else:
            log.info("Created admin user successfully")
            return True
    return False
Пример #5
0
 def init_db(self, uri="sqlite://"):
     Session.remove()
     engine = create_engine(uri)
     Session.configure(bind=engine)
     Base.metadata.create_all(bind=engine)
Пример #6
0
 def init_db(self):
     """ Bind our sqlalchemy engine and create any missing tables """
     Session.configure(bind=engine)
     Base.metadata.create_all(bind=engine)
Пример #7
0
 def init_db(self):
     """ Bind our sqlalchemy engine and create any missing tables """
     Session.configure(bind=engine)
     Base.metadata.create_all(bind=engine)
Пример #8
0
 def init_db(self, uri="sqlite://"):
     Session.remove()
     engine = create_engine(uri)
     Session.configure(bind=engine)
     Base.metadata.create_all(bind=engine)