fernandojunior/python-sqlite-orm

Automatically generate schema

Opened this issue · 0 comments

Find a way to automatically generate schema for Models

schema = '''
        drop table if exists post;

        create table model_name (
            id integer primary key autoincrement,
            ...
        );
        '''

A model must be something like this:

    class A(Model):
        a = int  # OK
        b = bool  # TODO
        c = float  # OK
        d = str  # OK
        e = chr  # TODO 'CHARACTER(1)'
        f = datetime  # TODO 'DATETIME' convert to timestamp
        b = {'unique':true, 'type': str}
        # ...
        def __init__(self):
            pass

    class B(Model):
        one = A
        def __init__(self):
            pass

    class C(Model):
        many = [B]
        def __init__(self):
            pass

References: