예제 #1
0
class MyClass:
    name: str = doctable.Col(unique=True)

    # builtin column types
    idx: int = doctable.IDCol()
    updated: datetime.datetime = doctable.UpdatedCol()
    added: datetime.datetime = doctable.AddedCol()

    # custom column types
    lon: float = doctable.Col()
    lat: float = doctable.Col()

    # use Col to use factory to construct emtpy list
    # will be stored as binary/pickle type, since no other available
    elements: Sequence = doctable.Col(list)

    # indices and constraints
    _indices_ = {
        doctable.Index('lonlat_index', 'lon', 'lat', unique=True),
        #'lonlat_index': ('lon', 'lat', {'unique':True}),
        #'name_index': ('name',),
        doctable.Index('name_index', 'name'),
    }
    _constraints_ = (
        doctable.Constraint('check', 'lon > 0', name='check_lon'),
        doctable.Constraint('check', 'lat > 0'),
        #('foreignkey', ('a','b'), ('c','d'))
    )
예제 #2
0
class CustomClass:
    '''This is my doc.'''
    __slots__ = []
    a: int
    b: int = doctable.Col(5)
    c: int = doctable.Col()

    # example method
    def aplusb(self):
        return self.a + self.b
예제 #3
0
class NoSlots:
    id: int = doctable.IDCol()
    a: int = doctable.Col()
    b: int = doctable.Col(5)
    c: int = doctable.Col(10)
    d: int = doctable.Col(10)
    e: int = doctable.Col(10)
    f: int = doctable.Col(10)
    g: int = doctable.Col(10)
    h: int = doctable.Col(10)
예제 #4
0
class WithSlots:
    __slots__ = []
    id: int = doctable.IDCol()
    a: int = doctable.Col()
    b: int = doctable.Col(5)
    c: int = doctable.Col(10)
    d: int = doctable.Col(10)
    e: int = doctable.Col(10)
    f: int = doctable.Col(10)
    g: int = doctable.Col(10)
    h: int = doctable.Col(10)
예제 #5
0
class DataObj:
    __slots__ = []
    id: int = doctable.Col()
    name1: str = doctable.Col()
    name2: str = doctable.Col()
    name3: str = doctable.Col()
    name4: str = doctable.Col()
    name5: str = doctable.Col()
    name6: str = doctable.Col()
    name7: str = doctable.Col()
    name8: str = doctable.Col()
    name9: str = doctable.Col()
    name10: str = doctable.Col()

    def __post_init__(self):
        if self.name1 is None:
            self.name1 = str(self.id)
            self.name2 = str(self.id)
            self.name3 = str(self.id)
            self.name4 = str(self.id)
            self.name5 = str(self.id)
            self.name6 = str(self.id)
            self.name7 = str(self.id)
            self.name8 = str(self.id)
            self.name9 = str(self.id)
            self.name10 = str(self.id)
예제 #6
0
class TestRow:
    __slots__ = []
    id: int = doctable.IDCol()
    doc: doctable.ParseTreeDoc = doctable.Col(type_kwargs=dict(
        folder='tmp/parsed_trees'))
예제 #7
0
class TestObj2(TestObjBase):
    data: list = doctable.Col(None,
                              coltype='picklefile',
                              type_args=dict(folder='tmp'))
예제 #8
0
class TestObj1(TestObjBase):
    data: list = doctable.Col(None)
예제 #9
0
class Child:
    __slots__ = []
    id: int = doctable.IDCol()
    name: str = doctable.Col()
    parent_name: str = doctable.Col()
예제 #10
0
class Parent:
    __slots__ = []
    id: int = doctable.IDCol()
    name: str = doctable.Col()
예제 #11
0
class FileObj:
    id: int = doctable.IDCol()
    data: np.ndarray = doctable.Col(None,
                                    coltype='picklefile',
                                    type_args=dict(folder=folder))
예제 #12
0
class DataObj:
    __slots__ = []
    id: int = doctable.IDCol()
    data: np.ndarray = doctable.Col(None)
예제 #13
0
class DataObj:
    arc: int = doctable.Col()
    name1: str = doctable.Col(type_args={'length':32})
    name2: str = doctable.Col(type_args={'length':32})
    name3: str = doctable.Col(type_args={'length':32})
    name4: str = doctable.Col(type_args={'length':32})
    name5: str = doctable.Col(type_args={'length':32})
    name6: str = doctable.Col(type_args={'length':32})
    name7: str = doctable.Col(type_args={'length':32})
    name8: str = doctable.Col(type_args={'length':32})
    name9: str = doctable.Col(type_args={'length':32})
    name10: str = doctable.Col(type_args={'length':32})
    def __post_init__(self):
        if self.name1 == doctable.EmptyValue():
            self.name1 = str(self.arc)
            self.name2 = str(self.arc)
            self.name3 = str(self.arc)
            self.name4 = str(self.arc)
            self.name5 = str(self.arc)
            self.name6 = str(self.arc)
            self.name7 = str(self.arc)
            self.name8 = str(self.arc)
            self.name9 = str(self.arc)
            self.name10 = str(self.arc)