python-sqlite-orm icon indicating copy to clipboard operation
python-sqlite-orm copied to clipboard

Automatically generate schema

Open fernandojunior opened this issue 9 years ago • 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:

fernandojunior avatar Mar 26 '16 21:03 fernandojunior