d2a/__init__.py
def declare(django_model, db_type=AUTO_DETECTED_DB_TYPE, back_type='backref'):
    """It converts a django model to alchemy orm object.
    :param django.db.models.base.Model django_model: Django model object or equivalent object.
    :param str db_type: Database type, for example `postgresql`. If omitted this option, it will be detected from django settings.
    :param str back_type: Back relation type, `backref` or ``None`` (it does not support `back_populates`).
    This function is also called from `transfer` :)
    """

    model_info = parse_model(django_model)
    if django_model in existing:
        return existing[django_model]

    rel_options = OrderedDict()
    attrs = OrderedDict({'__tablename__': model_info['table_name']})
    for name, fields in model_info['fields'].items():
        rel_option = fields.get('__rel_kwargs__', {})
        if rel_option:
            rel_options[name] = rel_option

        col_types = {}
        col_type_options = {}
        for _db_type in DB_TYPES:
            col_types[_db_type] = fields.get('__{}_type__'.format(_db_type), None)
            col_type_options[_db_type] = fields.get('__{}_type_kwargs__'.format(_db_type), {})

        type_key = 'default' if col_types.get(db_type) is None else db_type
        if col_types[type_key]:
            col_args = [col_types[type_key](**col_type_options[type_key])]
            if '__fk_kwargs__' in fields:
                col_args.append(ForeignKey(**_extract_kwargs(fields['__fk_kwargs__'])))

            column = attrs[name] = Column(*col_args, **_extract_kwargs(fields))
            rel_option['foreign_keys'] = [column]

    for logical_name, rel_option in rel_options.items():
        if '__secondary_model__' in rel_option:
            secondary = rel_option['secondary'] = declare(rel_option['__secondary_model__'], db_type=db_type, back_type=back_type).__table__
        
        if '__logical_name__' in rel_option:
            logical_name = rel_option['__logical_name__']

        back = rel_option.get('__back__', None)
        if back and back_type:
            rel_option[back_type] = back.rstrip('+').lower()

        attrs[logical_name] = relationship(rel_option['__target__'], **_extract_kwargs(rel_option))

    cls = existing[django_model] = type(model_info['table_name'], (Base,), attrs)
    return cls
It converts a django model to alchemy orm object.
    :param django.db.models.base.Model django_model: Django model object or equivalent object.
    :param str db_type: Database type, for example `postgresql`. If omitted this option, it will be detected from django settings.
    :param str back_type: Back relation type, `backref` or ``None`` (it does not support `back_populates`).
    This function is also called from `transfer` :)
    
It converts a django model to alchemy orm object.
It converts a django model to alchemy orm object .
def declare(django_model, db_type=AUTO_DETECTED_DB_TYPE, back_type='backref'):
    model_info = parse_model(django_model)
    if django_model in existing:
        return existing[django_model]
    rel_options = OrderedDict()
    attrs = OrderedDict({'__tablename__': model_info['table_name']})
    for name, fields in model_info['fields'].items():
        rel_option = fields.get('__rel_kwargs__', {})
        if rel_option:
            rel_options[name] = rel_option
        col_types = {}
        col_type_options = {}
        for _db_type in DB_TYPES:
            col_types[_db_type] = fields.get('__{}_type__'.format(_db_type), None)
            col_type_options[_db_type] = fields.get('__{}_type_kwargs__'.format(_db_type), {})
        type_key = 'default' if col_types.get(db_type) is None else db_type
        if col_types[type_key]:
            col_args = [col_types[type_key](**col_type_options[type_key])]
            if '__fk_kwargs__' in fields:
                col_args.append(ForeignKey(**_extract_kwargs(fields['__fk_kwargs__'])))
            column = attrs[name] = Column(*col_args, **_extract_kwargs(fields))
            rel_option['foreign_keys'] = [column]
    for logical_name, rel_option in rel_options.items():
        if '__secondary_model__' in rel_option:
            secondary = rel_option['secondary'] = declare(rel_option['__secondary_model__'], db_type=db_type, back_type=back_type).__table__
        if '__logical_name__' in rel_option:
            logical_name = rel_option['__logical_name__']
        back = rel_option.get('__back__', None)
        if back and back_type:
            rel_option[back_type] = back.rstrip('+').lower()
        attrs[logical_name] = relationship(rel_option['__target__'], **_extract_kwargs(rel_option))
    cls = existing[django_model] = type(model_info['table_name'], (Base,), attrs)
    return cls
def declare ( django_model , db_type = AUTO_DETECTED_DB_TYPE , back_type = 'backref' ) : model_info = parse_model ( django_model ) if django_model in existing : return existing [ django_model ] rel_options = OrderedDict ( ) attrs = OrderedDict ( { '__tablename__' : model_info [ 'table_name' ] } ) for name , fields in model_info [ 'fields' ] . items ( ) : rel_option = fields . get ( '__rel_kwargs__' , { } ) if rel_option : rel_options [ name ] = rel_option col_types = { } col_type_options = { } for _db_type in DB_TYPES : col_types [ _db_type ] = fields . get ( '__{}_type__' . format ( _db_type ) , None ) col_type_options [ _db_type ] = fields . get ( '__{}_type_kwargs__' . format ( _db_type ) , { } ) type_key = 'default' if col_types . get ( db_type ) is None else db_type if col_types [ type_key ] : col_args = [ col_types [ type_key ] ( ** col_type_options [ type_key ] ) ] if '__fk_kwargs__' in fields : col_args . append ( ForeignKey ( ** _extract_kwargs ( fields [ '__fk_kwargs__' ] ) ) ) column = attrs [ name ] = Column ( * col_args , ** _extract_kwargs ( fields ) ) rel_option [ 'foreign_keys' ] = [ column ] for logical_name , rel_option in rel_options . items ( ) : if '__secondary_model__' in rel_option : secondary = rel_option [ 'secondary' ] = declare ( rel_option [ '__secondary_model__' ] , db_type = db_type , back_type = back_type ) . __table__ if '__logical_name__' in rel_option : logical_name = rel_option [ '__logical_name__' ] back = rel_option . get ( '__back__' , None ) if back and back_type : rel_option [ back_type ] = back . rstrip ( '+' ) . lower ( ) attrs [ logical_name ] = relationship ( rel_option [ '__target__' ] , ** _extract_kwargs ( rel_option ) ) cls = existing [ django_model ] = type ( model_info [ 'table_name' ] , ( Base , ) , attrs ) return cls
It converts a django model to alchemy orm object.
It converts a django model to alchemy orm object .
"""It converts a django model to alchemy orm object.
    :param django.db.models.base.Model django_model: Django model object or equivalent object.
    :param str db_type: Database type, for example `postgresql`. If omitted this option, it will be detected from django settings.
    :param str back_type: Back relation type, `backref` or ``None`` (it does not support `back_populates`).
    This function is also called from `transfer` :)
    """
django_model
Django model object or equivalent object.
Django model object or equivalent object .
db_type
Database type, for example `postgresql`. If omitted this option, it will be detected from django settings.
Database type for example ` postgresql ` . If omitted this option it will be detected from django settings .
back_type
Back relation type, `backref` or ``None`` (it does not support `back_populates`).
This function is also called from `transfer` :)
Back relation type ` backref ` or ` ` None ` ` ( it does not support ` back_populates ` ) . This function is also called from ` transfer ` : )