Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 5
0
 def init_db(self, uri="sqlite://"):
     Session.remove()
     engine = create_engine(uri)
     Session.configure(bind=engine)
     Base.metadata.create_all(bind=engine)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 8
0
 def init_db(self, uri="sqlite://"):
     Session.remove()
     engine = create_engine(uri)
     Session.configure(bind=engine)
     Base.metadata.create_all(bind=engine)