示例#1
0
def add_dataset1():
    address = Address(street="123 Main St")
    address.save()
    address.reload()
    typeless_address = TypelessAddress(street="123 Main St")
    typeless_address.save()
    typeless_address.reload()

    for i in range(0, 100000):
        user1 = User(address_ref=address, address_id=address.id)
        user1.save(safe=False)
        user2 = TypelessUser(address_id=address.id, typeless_address=typeless_address)
        user2.save(safe=False)
示例#2
0
def add_dataset1():
    address = Address(street="123 Main St")
    address.save()
    address.reload()
    typeless_address = TypelessAddress(street="123 Main St")
    typeless_address.save()
    typeless_address.reload()

    for i in range(0, 100000):
        user1 = User(address_ref=address, address_id=address.id)
        user1.save(safe=False)
        user2 = TypelessUser(address_id=address.id,
                             typeless_address=typeless_address)
        user2.save(safe=False)
示例#3
0
from lib.core import Database
from examples.models import User

if __name__ == '__main__':
    conn = Database(db_name='test_db.sqlite').get_connection()

    # Create a table with name defined in __tablename__ attr of the model class.
    User(conn).create_table()

    # Insert a new row in the table. Currently ORM doesn't support uniqueness for pk.
    User(conn).insert(id=21, username='******')

    # Uncomment line below to update ALL the rows in the table with the values.
    # User(conn).update(id=1, username='******')

    # Search for all rows in table, then iterate over it
    print([x for x in User(conn).select_all()])

    # Uncomment line below to delete ALL rows in the related table
    # User(conn).delete()

    # Uncomment line below to DROP the table. This will delete data and schema.
    # User(conn).delete_table()
示例#4
0
 def setUp(self):
     self.orm.register(User)
     self.orm.register(Post)
     for username, password in izip(usernames, passwords):
         User(username=username, password=password).save(False)
     User.commit()
示例#5
0
 def setUp(self):
     with self.mapper.session().begin() as t:
         for username, password in zip(self.data.usernames,
                                       self.data.passwords):
             t.add(User(username=username, password=password))
     return t.on_result
示例#6
0
 def setUp(self):
     with User.transaction() as t:
         for username, password in zip(usernames, passwords):
             User(username=username, password=password).save(t)
示例#7
0
 def setUp(self):
     self.orm.register(User)
     self.orm.register(Post)
     for username,password in izip(usernames,passwords):
         User(username = username, password = password).save(False)
     User.commit()