摘要: F函数,用于操作对象的某一列的值 from django.db.models import F, Q from .models import Fruit fruit = Fruit.objects.get(id=1) fruit.count += 1 等同于 fruit.count= F("coun 阅读全文
posted @ 2021-07-17 16:55 x-dai 阅读(92) 评论(0) 推荐(0)
摘要: ​ Django-Redis latest django-redis 中文文档 Docs » django-redis 中文文档 ​ Edit on GitHub django-redis 中文文档 Andrey Antukh, niwi@niwi.be 4.7.0 翻译: RaPoSpectre 阅读全文
posted @ 2021-07-03 18:37 x-dai 阅读(223) 评论(0) 推荐(0)
摘要: ####环境 Django安装django-redis pip install django-redis Linux安装redis centos为例 进入官网找到下载地址 https://redis.io/download 下载完成后解压:tar -zxvf redisxxxx.tar.gz 解压完 阅读全文
posted @ 2021-07-03 15:59 x-dai 阅读(64) 评论(0) 推荐(0)
摘要: Python部分内置函数 class bytearray([source[, encoding[, errors]]]) 返回一个新的 bytes 数组。 bytearray 类是一个可变序列,包含范围为 0 <= x < 256 的整数。它有可变序列大部分常见的方法 可选形参 source 可以用 阅读全文
posted @ 2021-06-28 13:42 x-dai 阅读(82) 评论(0) 推荐(0)
摘要: 使用连接池意义 减少频繁和数据库建立连接从而耗费资源 pip install DBUtils 安装 第一步:创建数据库配置文件db_config.py import MySQLdb # 数据库信息,可以使用字典的格式来维护多个数据库连接信息 TEST_DB_CONFIG = { "host": "1 阅读全文
posted @ 2021-06-26 16:35 x-dai 阅读(535) 评论(0) 推荐(0)
摘要: 配置Mysql远程连接的方法 grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; flush privileges; 貌似在mysql8中会发生错误 Duplicate entry ' 阅读全文
posted @ 2021-06-25 18:39 x-dai 阅读(60) 评论(0) 推荐(0)
摘要: class SSHClient(): def __init__(self,host=None,port=22,username=None,password=None): self.host = host self.port = port self.username = username self.p 阅读全文
posted @ 2021-06-25 11:51 x-dai 阅读(879) 评论(0) 推荐(1)
摘要: APScheduler的安装 pip install apscheduler APScheduler由四部分组成 触发器:包含调度逻辑,每一个作业有它自己的触发器,用于决定接下来哪一个作业会运行。除了他们自己初始配置意外,触发器完全是无状态的 作业存储(job store):存储被调度的作业,默认的 阅读全文
posted @ 2021-06-24 17:23 x-dai 阅读(63) 评论(0) 推荐(0)
摘要: 插入前判断记录是否存在 语句格式: insert into table(field1,field2,。。)select value1,Value2,。。from DUAL where not exists(select 'id' from table where id=12) 如果id = 12 的 阅读全文
posted @ 2021-06-24 17:03 x-dai 阅读(1555) 评论(0) 推荐(0)
摘要: # 和数据库建立连接 connecter = MySQLdb.connect( host='127.0.0.1', port=3306, user='root', password='110396', db='restframework' ) cursor = connecter.cursor() 阅读全文
posted @ 2021-06-24 16:55 x-dai 阅读(121) 评论(0) 推荐(0)