Skip to main content

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

Project description

# 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.1
Filename, size File type Python version Upload date Hashes
Filename, size django_db_introspection-0.1-py3-none-any.whl (4.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-db-introspection-0.1.tar.gz (2.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page