예제 #1
0
def drop_table(table):
    """Drop the database."""

    print green("Dropping table %s" % table)
    with rw_transaction() as session:
        session.execute("drop table %s" % table)
        session.commit()
예제 #2
0
def fake_item(environment='development'):
    """Create fake item."""

    print green('Fake items')
    def random_text():
        return ''.join([random.choice(list('abcdefghijklmnopqrstuvwxyz')) for _ in xrange(7)])
    with rw_transaction() as session:
        new_record = MyTable('Hello', util.random_string())
        print 'Inserting {}'.format(new_record)
        session.add(new_record)
예제 #3
0
def fake_item(environment="development"):
    """Create fake item."""

    print green("Fake items")
    with rw_transaction() as session:
        user = User.get_mock_object()
        item = Item.get_mock_object()
        item.user_uuid = user.uuid
        print "Inserting user {}".format(user.to_primitive())
        print "Inserting item {}".format(item.to_primitive())
        model_user = ModelUser(**user.to_primitive())
        model_item = ModelItem(**item.to_primitive())
        session.add(model_user)
        session.add(model_item)