Example #1
0
class Footballer(Player):
    name = field.Column(storetype.Text(max_length=80))
    match_fk = rel.ManyToMany('Match', name='match')


class Match(Entity):
    id = field.PrimaryKey(storetype.Integer(), name='match_id')
    player_fk = rel.ManyToMany('Footballer', name='player')


m = Manager()
conf = ConnectionConfiguration(user="******",
                               password="******",
                               database="postgres")
m.connect(conf)
m.create_tables()

# EXAMPLE 1 ######################## simple insert, update, delete ##################################

monkey = Monkey()
monkey.animal_id = 1
monkey.mammal_type = 'humanoid'
monkey.monkey_name = 'Ham'
monkey.monkey_weight = 20.5

m.insert(monkey)
monkey.monkey_weight = 30.9
m.update(monkey)

find = m.find_by_id(Monkey(), 1)
print("\nI found a monkey!\nMammal type:", find.mammal_type, "Name:",