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 增删改查 语法的更多相关文章

  1. Hibernate基础增删改查语法

    1.创建好Hibernate项目,创建好实体类和测试类,如果不会创建Hibernate项目的同学,点此处:http://www.cnblogs.com/zhaojinyan/p/9336174.htm ...

  2. mysql增删改查语法

    MySQL 关注公众号"轻松学编程"了解更多. MySQL是关系型数据库,对大小写不敏感. MySQL属于关系型数据库, 优点: 复杂查询 可以用SQL语句方便的在一个表以及多个表 ...

  3. sql基本增删改查语法

    sql语法学习(适合新手) 1.插入数据 语法格式: INSERT [INTO] <表名> [列名] VALUES <值列表> insert into students(sna ...

  4. Mongodb常用增删改查语法

    1,新增 新增有两种方式 var Tank = mongoose.model('Tank', yourSchema); var small = new Tank({ size: 'small' }); ...

  5. Android_ADB 常用 shell命令 和 sqlite3 简单增删改查

    今天学习了一个ADB的常用命令.接下来简单使用几个常用ADB shell 命令. 首先我们得明白什么是adb.exe ADB -Android Debug Bridge, 是 Android sdk ...

  6. day38 mycql 初识概念,库(增删改查),表(增删改)以及表字段(增删改查),插入更新操作

    在Navicat中把已经生成的表逆向成模型 数据库上,右键-逆向数据库到模型 ego笔记: 增删改查 文件夹(库) 增 create database day43 charset utf8; 改 al ...

  7. MongoDB系列(三):增删改查(CURD)

    上篇讲了MongoDB的基础知识,大家应该对MongoDB有所了解了,当然真正用的还是curd操作,本篇为大家讲解MongoDB的curd操作. 1.数据库操作 #.增 use config #如果数 ...

  8. MVC——数据库增删改查(Razor)——Html语法

    一.显示界面 .Models(模板) private MyDBDataContext _context = new MyDBDataContext(); public List<Info> ...

  9. iOS使用sqlite3原生语法进行增删改查以及FMDB的使用

    首先要导入libsqlite3.dylib并且加入头文件#import <sqlite3.h>,在进行增删改查之前还要先把数据库搞进去. 一种方法是从外面拷贝到程序里:http://www ...

随机推荐

  1. Being a Good Boy in Spring Festival HDU - 1850

    桌子上有M堆扑克牌:每堆牌的数量分别为Ni(i=1…M):两人轮流进行:每走一步可以任意选择一堆并取走其中的任意张牌:桌子上的扑克全部取光,则游戏结束:最后一次取牌的人为胜者. 现在我们不想研究到底先 ...

  2. SQLServer2012数据库降级至SQLServer2008R2的方法

      一.  背景 因为对方的客户的服务器安装的数据版本2012,公司开发同事需要客户数据库的备份数据,但是公司数据版本是2008R2的,无法还原. 由于2012备份无法直接还原至2008R2(MSSQ ...

  3. css 选择器三

    2.4.10 浮动 浮动是css里面布局最多的一个属性,也是很重要的一个属性. float:表示浮动的意思.它有四个值. none: 表示不浮动,默认 left: 表示左浮动 right:表示右浮动 ...

  4. python迭代器概念与应用

    结论 )可迭代对象包含迭代器.2)如果一个对象拥有__iter__方法,其是可迭代对象:如果一个对象拥有next方法,其是迭代器.3)生成器是一种特殊的迭代器,生成器自动实现了“迭代器协议”(即__i ...

  5. leetcode_输入一个数组,目标树,检查目标是数组下标的哪两个之和,不准重复

    今天是leetcode第一天,但是不太顺利.做这些,想不到 原题目: 我给的答案: class Solution { public: vector<int> twoSum(vector&l ...

  6. 根据list集合某个字段进行排序

    import java.util.ArrayList; import java.util.List; class Student { private String name; private doub ...

  7. javaee登录界面

    首先在此之前我们应该正确安装数据库,以及eclipse(javaee)文件包. 1.首先在javaee中建立新的项目 2.右键点击WebContent-New-JSP File,新建jsp(动态)文件 ...

  8. python--model进阶

    一.QuerySet 1.可切片 使用Python 的切片语法来限制查询集记录的数目 .它等同于SQL 的LIMIT 和OFFSET 子句.  >>> Entry.objects.a ...

  9. Event IO Process

    先了解一下process和event loop EventLoop 除了异步Server和Client库之外,Swoole扩展还提供了直接操作底层epoll/kqueue事件循环的接口.可将其他扩展创 ...

  10. [转载]Python使用@property装饰器--getter和setter方法变成属性

    原贴:为什么Python不需要getter和setter getter 和 setter在java中被广泛使用.一个好的java编程准则为:将所有属性设置为私有的,同时为属性写getter和sette ...