예제 #1
0
파일: 6-2.py 프로젝트: GitForBruce/notes
def main():
    printf('*** Connect to %r database' % DBNAME)
    db = setup()
    if db not in DSNs:
        printf("\nERROR: %r not supported, exit" % db)
        return

    try:
        orm = SQLAlchemyTest(DSNs[db])
    except RuntimeError:
        printf('\nERROR: %r not supported, exit' %db)
        return

    printf('\n*** Create users table (drop one if appl.)')
    orm.drop(checkfirst=True)
    orm.create()

    printf('\n*** Insert names into table')
    orm.insert()
    orm.dbDump()

    printf('\n*** Move users to a random group')
    fr, to ,num = orm.update()
    printf('\t(%d users moved from (%d) to (%d)' %(num, fr, to))
    orm.dbDump()

    printf('\n*** Randomly delete group')
    rm, num = orm.delete()
    printf('\t(group #%d; %d users removed)' %(rm, num))
    orm.dbDump()

    printf('\n*** Drop users table')
    orm.drop()
    printf('\n*** Close cxns')
    orm.finish()
예제 #2
0
def main():
    printf('*** Connect to %r database' % DBNAME)
    db = setup()
    if db not in DSNs:
        printf('\nERROR: %r not supported, exit' % db)
        return

    try:
        orm = SQLAlchemyTest(DSNs[db])
    except RuntimeError:
        printf('\nERROR: %r not supported, exit' % db)
        return

    printf('\n*** Create users table (drop old one if appl.)')
    orm.drop(checkfirst=True)
    orm.create()

    printf('\n*** Insert names into table')
    orm.insert()
    orm.dbDump()

    printf('\n*** Move users to a random group')
    fr, to, num = orm.update()
    printf('\t(%d users moved) from (%d) to (%d)' % (num, fr, to))
    orm.dbDump()

    printf('\n*** Randomly delete group')
    rm, num = orm.delete()
    printf('\t(group #%d; %d users removed)' % (rm, num))
    orm.dbDump()

    printf('\n*** Drop users table')
    orm.drop()
    printf('\n*** Close cxns')
    orm.finish()
예제 #3
0
def main():
    print("*** Connect to %r database" % DBNAME)
    db = setup()
    if db not in DSN:
        print("\nERROR: %r not supported, exit" % db)
        return

    try:
        orm = SQLAlchemyTest(DSN[db])
    except RuntimeError:
        print("\nERROR: %r not supported, exit" % db)
        return

    print("\n*** Create users table (drop old table if present)")
    orm.drop(checkfirst=True)
    orm.create()

    print("\n*** Insert names into table")
    orm.insert()
    orm.dbDump()

    print("\n*** Move users to a random group")
    fr, to, num = orm.update()
    print("\t(%d users moved) from (%d) to (%d)" % (num, fr, to))
    orm.dbDump()

    print("\n*** Randomly delete group")
    rm, num = orm.delete()
    print("\t(group #%d; %d users removed)" % (rm, num))
    orm.dbDump()

    print("\n*** Drop users table")
    orm.drop()
    print("\n*** Close cxns")
    orm.finish()
예제 #4
0
def main():
    try:
        orm = StuOperation(DSN)
    except RuntimeError:
        print('Error:not supported\n')
        return
    if orm.exists():
        orm.drop()
    orm.create()
    # orm.delete(22)
    # orm.get_all()
    for sid in range(1, 3000):
        name = "".join(random.choices(string.ascii_letters, k=10))
        gender = random.choice(['F', 'M'])
        for cid in range(1, 6):
            score = random.randint(1, 100)
            orm.insert(sid=sid, name=name, gender=gender, cid=cid, score=score)
    orm.finish()
예제 #5
0
def main():
    print("*** Connect to %r database" % DB_NAME)

    orm = SQLAlchemyTest(DSN)

    print("*** Create users table")
    orm.drop(checkfirst=True)
    orm.create()

    print("*** Insert names into table")
    orm.insert()
    orm.db_dump()

    print("*** Move users to random group")
    fr, to, num = orm.update()
    orm.db_dump()

    print("** Randomly delete group")
    rm, num = orm.delete()
    orm.db_dump()

    print("*** Drop users table")
    orm.drop()
    orm.finish()