Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funnyang/easy_queryset
快速使用 Django QuerySet
https://github.com/funnyang/easy_queryset
django orm queryset
Last synced: about 1 month ago
JSON representation
快速使用 Django QuerySet
- Host: GitHub
- URL: https://github.com/funnyang/easy_queryset
- Owner: Funnyang
- License: mit
- Created: 2020-03-16T15:30:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-22T08:57:08.000Z (almost 5 years ago)
- Last Synced: 2024-11-13T00:06:26.116Z (3 months ago)
- Topics: django, orm, queryset
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Easy QuerySet
Django 的 ORM 是我用过最好用的,但无法快速地单独使用,按照官方指示,要写好几行代码。
这个项目只是做了小小的封装,只是为了方便地使用 Django Models 来写脚本。
## 安装
```shell
pip install easy_queryset
```## 示例
```python
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()
```