it converts a django model to a sqlalchemy declaration
Project description
it converts a django model to a sqlalchemy declaration.
Requirements
Python 3.6 (not tested)
Django 1.4 ~ 1.11 (not tested)
Install
$ pip install d2a
Usage
For example you make models_sqla.py at a directory which models.py has been placed on.
And write like the following to the models_sqla.py:
from d2a import copy from . import models copy(models, globals())
That’s all, you can import sqlalchemy declaration made from django model.
Example: demo/models.py and demo/models_sqla.py exist.
>>> from demo import models <module 'demo.models' from 'djangomodel2alchemymap/sample/demo/models.py'> >>> models. # tab tab tab -> Test is declared. models.Test( models.models models.uuid >>> from demo import models_sqla >>> models_sqla.Test # Test is declared as sqlalchemy declaration ! <class 'd2a.alchemy.test_table'> >>> models_sqla.Test.__table__ # and got Table ! yatta! Table('test_table', MetaData(bind=None), Column('id', CHAR(length=32), table=<test_table>, primary_key=True, nullable=False), Column('no', INTEGER(), table=<test_table>, nullable=False), Column('created', DateTime(), table=<test_table>, nullable=False), Column('updated', DateTime(), table=<test_table>, nullable=False), Column('type', VARCHAR(length=20), table=<test_table>, nullable=False), Column('description', Text(), table=<test_table>), Column('status', VARCHAR(length=10), table=<test_table>), Column('category', VARCHAR(length=255), table=<test_table>), schema=None)
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
d2a-0.0.1.tar.gz
(3.5 kB
view details)
File details
Details for the file d2a-0.0.1.tar.gz
.
File metadata
- Download URL: d2a-0.0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9434c4df9bb7b0a2e0c4bf5ace98b16e13ecaa02f307e17f451651d714c2bc4 |
|
MD5 | 09af9cacdfeed27979c2db7155c779ba |
|
BLAKE2b-256 | afbb9b26bb08740863018c459944dbbf9b9fb291af9b043b348dc1af3c6f7785 |