day 68 增删改查 语法
1 普通正则
2 分组正则
url(r'/blog/(\d+)/(\d+)',views.blog) blog(request,arq1,arq2) 按照位置传参
3 分组命名
url(r'/blog/(?P<year>\d+)/(?P<month>\d+)',views.blog) blog(request,year,month)
4 用name 指定别名
url(r'/blog/(?P<year>\d+)/(?P<month>\d+)',views.blog,name ='blog') blog(request,year,month
涉及到了反向解析URL
4-1 在html里面:{% url 'blog' 2012 12%}
4-2from django.urls import reverse reverse ('blog',arg=(2013,11))
5 用namespace 指定命名空间
url(r'/app01/',inclue(app01.urls,namespace='app01))
涉及到了反向解析URL
5-1 HTML 里面{% url 'app01:blog' 2012 11%}
5-22 在views reverse('app01:blog' ,arg=(2010,33))
--------------
通过get取值 和通关过分组取值的用法和对比
get 和分组取值
1 HTML 里面{% url 'app01:blog' 2012 11%}
2 在views reverse('app01:blog' ,arg=(2010,33))
要在Django Console 打印出有sq语句 在django 项目的配置信息中加上这个日志 而且引用
logging
models 中插入这句在定义的类的下面的缩进行里 这样打印出来的结果对象就会是实际的内容
def __str__(self):
return '{}{}'.format(self.cname,self.first_day)
单表查询的增删改查
单表查询的API 介绍 共13条
1 返回QuerySet对象的有8条
1 all():全部 2 filter():过滤 3 exclude():不包括
4 value()值 5value_list() 值的列表 6 order_by() 排序正序
7 reverse() 反转 8 distinct() 去重
models.Ban_list.objects.filter(id=7)
<QuerySet [<Ban_list: Linux 1212期2015-01-29>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` = 7 LIMIT 21; args=(7,)
(0.000) SELECT VERSION(); args=None
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` = 7 LIMIT 21; args=(7,)
.all()
filter() 支持链式操作
exclude() 不包含
.value() 单列 多列 是字典
.value_list() 元祖
.order_by() 排序
all().order_by('id)默认id排序 -id反序
.reverse() 和order_by('-id)
.distinct() 去重 保留前者
2返回数字的: 1 count():计数行数
.count() 计算多少行
3返回布尔值的:1exists():是否存在
4 返回的是对象的:1 get() 得到的是一个对象 2 first():第一个对象 3 last() :最后一个对象
.get() 取单个对象
.first() .last() 对象
以下都是在左下角Python Console
1 Queryset 对象8个
models.Ban_list.objects.get(id=7)
(0.001) SELECT @@SQL_AUTO_IS_NULL; args=None
(0.001) SELECT VERSION(); args=None
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` = 7; args=(7,)
<Ban_list: Linux 1212期2015-01-29>
models.Ban_list.objects.all()
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` LIMIT 21; args=()
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>]>
(0.001) SELECT @@SQL_AUTO_IS_NULL; args=None
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` LIMIT 21; args=()
models.Ban_list.objects.filter(id=7)
<QuerySet [<Ban_list: Linux 1212期2015-01-29>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` = 7 LIMIT 21; args=(7,)
(0.000) SELECT VERSION(); args=None
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` = 7 LIMIT 21; args=(7,)
models.Ban_list.objects.filter(cname='大数据1班').first()
<Ban_list: 大数据1班2020-12-01>
(0.061) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`cname` = '大数据1班' ORDER BY `app0001_ban_list`.`id` ASC LIMIT 1; args=('大数据1班',)
models.Ban_list.objects.exclue(cname='大数据1班')
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'Manager' object has no attribute 'exclue'
models.Ban_list.objects.exclude(cname='大数据1班')
(0.005) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
models.Ban_list.objects.exclude(cname='大数据1班').values('cname')
<QuerySet [{'cname': 'Python 18期'}, {'cname': 'Linux 1212期'}, {'cname': 'Python 11期'}, {'cname': 'Linux 4期'}, {'cname': 'Python 19期'}, {'cname': '大数据2班'}]>
(0.002) SELECT `app0001_ban_list`.`cname` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
(0.001) SELECT `app0001_ban_list`.`cname` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
models.Ban_list.objects.exclude(cname='大数据1班').values('cname','first_day')
(0.001) SELECT `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
<QuerySet [{'cname': 'Python 18期', 'first_day': datetime.date(2023, 10, 19)}, {'cname': 'Linux 1212期', 'first_day': datetime.date(2015, 1, 29)}, {'cname': 'Python 11期', 'first_day': datetime.date(2012, 9, 1)}, {'cname': 'Linux 4期', 'first_day': datetime.date(2019, 12, 23)}, {'cname': 'Python 19期', 'first_day': datetime.date(2016, 10, 19)}, {'cname': '大数据2班', 'first_day': datetime.date(2017, 10, 28)}]>
(0.001) SELECT `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
models.Ban_list.objects.exclude(cname='大数据1班').values_list('cname','first_day')
(0.003) SELECT `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
<QuerySet [('Python 18期', datetime.date(2023, 10, 19)), ('Linux 1212期', datetime.date(2015, 1, 29)), ('Python 11期', datetime.date(2012, 9, 1)), ('Linux 4期', datetime.date(2019, 12, 23)), ('Python 19期', datetime.date(2016, 10, 19)), ('大数据2班', datetime.date(2017, 10, 28))]>
(0.001) SELECT `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') LIMIT 21; args=('大数据1班',)
models.Ban_list.objects.exclude(cname='大数据1班').order_by('first_day')
<QuerySet [<Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 18期2023-10-19>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') ORDER BY `app0001_ban_list`.`first_day` ASC LIMIT 21; args=('大数据1班',)
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE NOT (`app0001_ban_list`.`cname` = '大数据1班') ORDER BY `app0001_ban_list`.`first_day` ASC LIMIT 21; args=('大数据1班',)
models.Ban_list.objects.all().order_by('first_day')
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`first_day` ASC LIMIT 21; args=()
<QuerySet [<Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: 大数据1班2018-01-10>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Python 18期2023-10-19>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`first_day` ASC LIMIT 21; args=()
models.Ban_list.objects.all()
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` LIMIT 21; args=()
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: 大数据1班2018-01-10>]>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` LIMIT 21; args=()
models.Ban_list.objects.all().order_by('id')
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` ASC LIMIT 21; args=()
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: 大数据1班2018-01-10>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` ASC LIMIT 21; args=()
models.Ban_list.objects.all().order_by('-id')
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` DESC LIMIT 21; args=()
<QuerySet [<Ban_list: 大数据1班2018-01-10>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: Python 19期2016-10-19>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 11期2012-09-01>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: Python 18期2023-10-19>]>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` DESC LIMIT 21; args=()
models.Ban_list.objects.all().reverse()
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: 大数据1班2018-01-10>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` LIMIT 21; args=()
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` LIMIT 21; args=()
models.Ban_list.objects.all().order_by('id').reverse()
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` DESC LIMIT 21; args=()
<QuerySet [<Ban_list: 大数据1班2018-01-10>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: Python 19期2016-10-19>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 11期2012-09-01>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: Python 18期2023-10-19>]>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` DESC LIMIT 21; args=()
models.Ban_list.objects.values('cname').distinct()
(0.003) SELECT DISTINCT `app0001_ban_list`.`cname` FROM `app0001_ban_list` LIMIT 21; args=()
<QuerySet [{'cname': 'Python 18期'}, {'cname': 'Linux 1212期'}, {'cname': '大数据1班'}, {'cname': 'Python 11期'}, {'cname': 'Linux 4期'}, {'cname': 'Python 19期'}, {'cname': '大数据2班'}]>
(0.002) SELECT DISTINCT `app0001_ban_list`.`cname` FROM `app0001_ban_list` LIMIT 21; args=()
2 数字的一个
models.Ban_list.objects.all().count()
8
(0.001) SELECT COUNT(*) AS `__count` FROM `app0001_ban_list`; args=()
3对象的3个
models.Ban_list.objects.all().first()
<Ban_list: Python 18期2023-10-19>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` ASC LIMIT 1; args=()
models.Ban_list.objects.all().last()
<Ban_list: 大数据1班2018-01-10>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` ORDER BY `app0001_ban_list`.`id` DESC LIMIT 1; args=()
models.Ban_list.objects.get(id=7)
<Ban_list: Linux 1212期2015-01-29>
(0.002) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` = 7; args=(7,)
models.Ban_list.objects.filter(first_day__month=12)
<QuerySet [<Ban_list: 大数据1班2020-12-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: linux 12期2017-12-12>]>
(0.014) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 LIMIT 21; args=(12,)
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 LIMIT 21; args=(12,)
models.Ban_list.objects.filter(first_day__month=12,first_day__year=2018)
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE (EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 AND `app0001_ban_list`.`first_day` BETWEEN '2018-01-01' AND '2018-12-31') LIMIT 21; args=(12, '2018-01-01', '2018-12-31')
<QuerySet []>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE (EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 AND `app0001_ban_list`.`first_day` BETWEEN '2018-01-01' AND '2018-12-31') LIMIT 21; args=(12, '2018-01-01', '2018-12-31')
逻辑运算
models.Ban_list.objects.filter(id__gt=1) 大于
(0.076) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` > 1 LIMIT 21; args=(1,)
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>, <Ban_list: 大数据1班2020-12-01>, <Ban_list: Python 11期2012-09-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: Python 19期2016-10-19>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: 大数据1班2018-01-10>]>
(0.014) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` > 1 LIMIT 21; args=(1,)
models.Ban_list.objects.filter(id__lt=10) 小于
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>]>
(0.017) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` < 10 LIMIT 21; args=(10,)
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` < 10 LIMIT 21; args=(10,)
models.Ban_list.objects.filter(id__in=[2,7,2]) 包含里面
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` IN (2, 7) LIMIT 21; args=(2, 7)
<QuerySet [<Ban_list: Python 18期2023-10-19>, <Ban_list: Linux 1212期2015-01-29>]>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`id` IN (2, 7) LIMIT 21; args=(2, 7)
查找
models.Ban_list.objects.filter(cname__contains='大数据') 模糊查找
(0.030) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`cname` LIKE BINARY '%大数据%' LIMIT 21; args=('%大数据%',)
<QuerySet [<Ban_list: 大数据1班2020-12-01>, <Ban_list: 大数据2班2017-10-28>, <Ban_list: 大数据1班2018-01-10>]>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`cname` LIKE BINARY '%大数据%' LIMIT 21; args=('%大数据%',)
不区分大小写的cname__icontains
models.Ban_list.objects.filter(cname__icontains='linux')
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`cname` LIKE '%linux%' LIMIT 21; args=('%linux%',)
<QuerySet [<Ban_list: Linux 1212期2015-01-29>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: linux 12期2017-12-12>]>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`cname` LIKE '%linux%' LIMIT 21; args=('%linux%',)
关于时间查找
import datetime
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE `app0001_ban_list`.`cname` LIKE '%linux%' LIMIT 21; args=('%linux%',)
datetime.datetime.now()
datetime.datetime(2018, 1, 22, 21, 7, 48, 987579)
datetime.datetime.now().year
2018
datetime.datetime.now().day
22
models.Ban_list.objects.filter(first_day__month=12)
<QuerySet [<Ban_list: 大数据1班2020-12-01>, <Ban_list: Linux 4期2019-12-23>, <Ban_list: linux 12期2017-12-12>]>
(0.014) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 LIMIT 21; args=(12,)
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 LIMIT 21; args=(12,)
models.Ban_list.objects.filter(first_day__month=12,first_day__year=2018)
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE (EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 AND `app0001_ban_list`.`first_day` BETWEEN '2018-01-01' AND '2018-12-31') LIMIT 21; args=(12, '2018-01-01', '2018-12-31')
<QuerySet []>
(0.001) SELECT `app0001_ban_list`.`id`, `app0001_ban_list`.`cname`, `app0001_ban_list`.`first_day` FROM `app0001_ban_list` WHERE (EXTRACT(MONTH FROM `app0001_ban_list`.`first_day`) = 12 AND `app0001_ban_list`.`first_day` BETWEEN '2018-01-01' AND '2018-12-31') LIMIT 21; args=(12, '2018-01-01', '2018-12-31')
day 68 增删改查 语法的更多相关文章
- Hibernate基础增删改查语法
1.创建好Hibernate项目,创建好实体类和测试类,如果不会创建Hibernate项目的同学,点此处:http://www.cnblogs.com/zhaojinyan/p/9336174.htm ...
- mysql增删改查语法
MySQL 关注公众号"轻松学编程"了解更多. MySQL是关系型数据库,对大小写不敏感. MySQL属于关系型数据库, 优点: 复杂查询 可以用SQL语句方便的在一个表以及多个表 ...
- sql基本增删改查语法
sql语法学习(适合新手) 1.插入数据 语法格式: INSERT [INTO] <表名> [列名] VALUES <值列表> insert into students(sna ...
- Mongodb常用增删改查语法
1,新增 新增有两种方式 var Tank = mongoose.model('Tank', yourSchema); var small = new Tank({ size: 'small' }); ...
- Android_ADB 常用 shell命令 和 sqlite3 简单增删改查
今天学习了一个ADB的常用命令.接下来简单使用几个常用ADB shell 命令. 首先我们得明白什么是adb.exe ADB -Android Debug Bridge, 是 Android sdk ...
- day38 mycql 初识概念,库(增删改查),表(增删改)以及表字段(增删改查),插入更新操作
在Navicat中把已经生成的表逆向成模型 数据库上,右键-逆向数据库到模型 ego笔记: 增删改查 文件夹(库) 增 create database day43 charset utf8; 改 al ...
- MongoDB系列(三):增删改查(CURD)
上篇讲了MongoDB的基础知识,大家应该对MongoDB有所了解了,当然真正用的还是curd操作,本篇为大家讲解MongoDB的curd操作. 1.数据库操作 #.增 use config #如果数 ...
- MVC——数据库增删改查(Razor)——Html语法
一.显示界面 .Models(模板) private MyDBDataContext _context = new MyDBDataContext(); public List<Info> ...
- iOS使用sqlite3原生语法进行增删改查以及FMDB的使用
首先要导入libsqlite3.dylib并且加入头文件#import <sqlite3.h>,在进行增删改查之前还要先把数据库搞进去. 一种方法是从外面拷贝到程序里:http://www ...
随机推荐
- Confluence 6 从一个模板中创建一个空间
Confluence 已经存储了一系列的模板,这些模板被称为 空间蓝图(space blueprints),这模板具有一些自定义的主页,边栏或者可能有蓝图页面或一些示例内容来帮助你开始使用 Confl ...
- 十分钟搞定pandas内容
目录 十分钟搞定pandas 一.创建对象 二.查看数据 三.选择器 十二.导入和保存数据 参考:http://pandas.pydata.org/pandas-docs/stable/whatsne ...
- Runable和Thread
Java多线程 java中有两种实现多线程的方式: 1. 一种是通过继承Thread类,同时重写run()方法.但是java中,只允许单继承,也就是一个类只能继承一个父类,使得该方式具有一定的局限性, ...
- 第一阶段——站立会议总结DAY03
昨天忘记发了,补充... 1.昨天做了什么:继续做界面的设计,使其更加美观. 2.今天准备做什么:准备将点击按钮时跳转到一个修改密码界面. 3.遇到的困难:此次第一阶段的任务是一个框架,不知道可否实现 ...
- spring boot(十八)集成FastDFS文件上传下载
上篇文章介绍了如何使用Spring Boot上传文件,这篇文章我们介绍如何使用Spring Boot将文件上传到分布式文件系统FastDFS中. 这个项目会在上一个项目的基础上进行构建. 1.pom包 ...
- Matlab-2:二分法工具箱
function g=dichotomy(f,tol) %this routine uses bisection to find a zero of user-supplied %continuous ...
- [LeetCode] 108. Convert Sorted Array to Binary Search Tree ☆(升序数组转换成一个平衡二叉树)
108. Convert Sorted Array to Binary Search Tree 描述 Given an array where elements are sorted in ascen ...
- OpenJDK换为JDK(CentOS)
说明:应该来说没必要非把OpenJDK卸载掉,只要让$PATH中我们安装的jdk的目录较OpenJDK所在的/usr/bin先出现就好了:简言之跳过下边的第一步直接从第二步开始更科学一些. 1.卸载O ...
- 回声UDP服务器端/客户端
UDP是具有数据边界的协议,传输中调用I/O函数的次数非常重要.输入函数的调用次数要和输出函数的调用次数完全一致,这样才能保证接受全部已发送的数据. TCP套接字中需注册待传输数据的目标IP和端口,而 ...
- 函数后面跟throw
1.函数后面跟throw(),表示该函数不会抛出异常 2.函数后面跟throw(...),表示该函数可能会抛出任何形式的异常 3.函数后面跟throw(int),表示该函数只抛出int类型的异常