Skip to main content

django queryset for script

Project description

Easy QuerySet

Django 的 ORM 是我用过最好用的,但无法快速地单独使用,按照官方指示,要写好几行代码。

这个项目只是做了小小的封装,只是为了方便地使用 Django Models 来写脚本。

安装

pip install easy_queryset

示例

from easy_queryset import models, add_mysql
# 数据库配置
add_mysql('localhost', 'username', 'password', 'example_db')
add_mysql('localhost', 'username', 'password', 'example_db', app_label="example")

class Users(models.Model):
    id = models.CharField()
    name = models.CharField()
    email = models.CharField()

    class Meta:
        app_label = "default" # 指定数据库配置
        db_table = "users"


class Group(models.Model):
    id = models.CharField()
    name = models.CharField()
    email = models.CharField()

    class Meta:
        app_label = "example" # 指定数据库配置
        db_table = "group"

Users.objects.all()
Group.objects.all()

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 easy-queryset, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size easy_queryset-0.0.5-py3-none-any.whl (4.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size easy_queryset-0.0.5.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

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