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)
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()
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()
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
def setUp(self): with User.transaction() as t: for username, password in zip(usernames, passwords): User(username=username, password=password).save(t)
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()