Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Django database introspection tool, through the data table name can dynamically create a Django models ready-to-use objects.

Project description

# django-db-introspection
pip3 install django-db-introspection
Django 数据库内省工具, 通过数据表名就可以动态创建一个即时可用的Django models对象。
仅仅需要一个表名,你就可以立即得到一个可用的Django 模型,并立即进行查询,更新等操作,开箱即用。
# -------------------------------
Django database introspection tool, through the data table name can dynamically create a Django models ready-to-use objects.
Just need a table name, you can immediately get a usable Django model, and immediately query, update and other operations, out of the box.
The current version does not support foreign key relationships.
# -------------------------------
In [4]: from django-db-introspection.introspection import get_my_models

In [5]: client_device_user = ModelFactory('monkey_king', 'client_device_user').models
class ClientDeviceUser(models.Model):
box_id = models.CharField(max_length=20)
device_id = models.CharField(max_length=50, blank=True, null=True)
user_id = models.CharField(max_length=37)
name4user = models.CharField(max_length=50, blank=True, null=True)
email = models.IntegerField(blank=True, null=True)
sms = models.IntegerField(blank=True, null=True)
voice = models.IntegerField(blank=True, null=True)
push = models.IntegerField(blank=True, null=True)
master = models.IntegerField(blank=True, null=True)
agent = models.IntegerField(blank=True, null=True)
class Meta:
/usr/local/lib/python3.5/dist-packages/django/db/models/ RuntimeWarning: Model 'monkey_king.clientdeviceuser' wasalready registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models.
new_class._meta.apps.register_model(new_class._meta.app_label, new_class)

In [6]: client_device_user.objects.first().box_id
Out[6]: '01J01ELQ15'

In [7]:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-db-introspection, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size django_db_introspection-0.2-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-db-introspection-0.2.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page