Esempio n. 1
0
 class Foo(Base):
     DB_TABLE = 'foos'
     c1 = INT()
     c2 = BOOL()
     c3 = DATE()
     c4 = DATETIME()
     c5 = VARCHAR()
     c6 = VARCHAR(null=True, blank=False)
     c7 = TEXT(null=True, validate=dict(re=r'\Ax'))
     c8 = BLOB(null=True)
Esempio n. 2
0
 class Foo(Base):
     DB_TABLE = 'foos'
     abc = INT(
         choices=XEnum(
             qw('value label title'),
             A=(1, 'AA', 'aaa'),
             B=(2, 'BB', 'bbb'),
             C=(4, 'CC', 'ccc'),
         ),
         multiple=True,
         default=3,
         null=True,
     )
     efg = INT(choices={
         1: 'ONE',
         2: 'TWO',
         4: 'FOUR'
     },
               multiple=True,
               default=2,
               null=True)
     xyz = VARCHAR(choices=XEnum(X='x', Y='y', Z='z'),
                   default='x',
                   null=True)
     flag = BOOL(choices={
         True: 'ON',
         False: 'OFF'
     },
                 default=True,
                 null=True)
Esempio n. 3
0
    class Baz(Base):
        DB_TABLE = 'bazs'

        id = INT(primary_key=True)
        bar_id = BELONGS_TO(Bar)
        baz = VARCHAR()
        is_last = BOOL()
Esempio n. 4
0
    class Bar(Base):
        DB_TABLE = 'bars'

        id = INT(primary_key=True)
        foo_id = BELONGS_TO(Foo)
        bar = VARCHAR()

        bazs = HasMany('Baz', 'bar_id', order_by='id')
        bar2 = HasOne('Bar2')
        last_baz = HasOne('Baz',
                          lambda q, r: q.where(bar_id=r.id, is_last=True))
Esempio n. 5
0
 class Bar(Base):
     DB_INDEXES = (
         dict(prefix='UNIQUE', on=('foo_id', 'rad')),
     )
     DB_TABLE = 'bars'
     id = INT(auto_increment=True, primary_key=True)
     foo_id = BELONGS_TO(Foo)
     created_by = BELONGS_TO(User)
     created_at = DATETIME(default=NOW)
     updated_by = BELONGS_TO(User)
     updated_at = DATETIME(default=NOW)
     lock_version = INT(default=1)
     name = VARCHAR(default='?', unique=True, blank=False)
     chks = INT(choices=XEnum(A=1, B=2, C=4), multiple=True)
     rad = BOOL(choices={True: 'ON', False: 'OFF'})
Esempio n. 6
0
 class StrPk(Base):
     DB_TABLE = 'str_pks'
     id = VARCHAR(primary_key=True)
Esempio n. 7
0
 class Foo(Base):
     DB_TABLE = 'foos'
     id = INT(auto_increment=True, primary_key=True)
     name = VARCHAR()
Esempio n. 8
0
    class Foo(Base):
        DB_TABLE = 'foos'

        id = INT(primary_key=True)
        foo = VARCHAR()
        bars = HasMany('Bar', order_by=('id', ))
Esempio n. 9
0
 class Baz(Base):
     DB_TABLE = 'bazs'
     name = VARCHAR()
Esempio n. 10
0
 class User(Base):
     DB_TABLE = 'users'
     id = INT(auto_increment=True, primary_key=True)
     name = VARCHAR()
Esempio n. 11
0
 class Baz(Base):
     DB_TABLE = 'bazs'
     id = DATE(primary_key=True)
     name = VARCHAR()
Esempio n. 12
0
    class Foo(Base):
        DB_TABLE = 'foos'

        id = INT(primary_key=True)
        foo = VARCHAR()