Пример #1
0
def init_db(dbname=None):
    """"Initialization database """
    if dbname != None:
        exec('from orm.' + dbname + ' import create_engine, Base_to')
        engine = create_engine(Configuretion(dbname),
                               encoding=Config[dbname]['encoding'], echo=Config[dbname]['echo'])
        Base_to.metadata.create_all(engine)
    else:
        for item in Config:
            exec('from orm.' + item + ' import create_engine, Base_to')
            engine = create_engine(Configuretion(item),
                                   encoding=Config[item]['encoding'], echo=Config[item]['echo'])
            Base_to.metadata.create_all(engine)
Пример #2
0
def returns_session(dbname):
    from orm.Judgment import sessionmaker, create_engine

    engine = create_engine(Configuretion(dbname),
                           pool_size=20, max_overflow=100,
                           encoding=Config[dbname]['encoding'], echo=Config[dbname]['echo'])
    to_Session = sessionmaker(expire_on_commit=False)
    to_Session.configure(bind=engine)

    return to_Session
Пример #3
0
def returns_session(dbname):
    from orm.Judgment import sessionmaker, create_engine

    engine = create_engine(Configuretion(dbname),
                           pool_size=20, max_overflow=100,
                           encoding=Config[dbname]['encoding'], echo=Config[dbname]['echo'])
    to_Session = sessionmaker(expire_on_commit=False)
    to_Session.configure(bind=engine)

    return to_Session

if __name__ == '__main__':
    init_db()
    from orm.Sqlextend import SearchName, sessionmaker, Base_to, create_engine
    item = 'Sqlextend'
    engine = create_engine(Configuretion(
        item), encoding=Config[item]['encoding'], echo=Config[item]['echo'])

    to_Session = sessionmaker(expire_on_commit=False)
    to_Session.configure(bind=engine)
    #t_session = to_Session()
    insert = SearchName()
    point = Opration(to_Session, editor=insert, tablename=SearchName,
                     filter='name != ""', limit=10)

    for item in ['test12222', 'test23333', 'test32222', 'test']:
        insert.name = item
        point.set_value(insert)
        point.update()

    for item in point.query():
        insert.id = item.id