08 2019 档案

摘要:from datetime import datetimefrom django.http import HttpResponse, HttpResponseRedirectfrom django.shortcuts import render,render_to_response,redirect 阅读全文
posted @ 2019-08-30 09:51 EricBlog 阅读(122) 评论(0) 推荐(0)
摘要:pip install django python import django django.__version__ 查看版本 '2.2.3' pip uninstall django 卸载 安装指定版本 pip install django==1.11.18 django-admin.py sta 阅读全文
posted @ 2019-08-29 14:56 EricBlog 阅读(111) 评论(0) 推荐(0)
摘要:https://api.mongodb.com/python/current/tutorial.html# 文档地址from pymongo import MongoClientfrom gridfs import *client = MongoClient(host = "localhost", 阅读全文
posted @ 2019-08-28 10:46 EricBlog 阅读(617) 评论(0) 推荐(0)
摘要:pip install pymongo 单行写入 5d63770002712ae609b67e61 Jack5d64c68516dce5bd516c0de2 李璐5d64c68516dce5bd516c0de3 陈刚5d64c68516dce5bd516c0de4 郭丽丽 5d64c68516dce 阅读全文
posted @ 2019-08-27 16:28 EricBlog 阅读(193) 评论(0) 推荐(0)
摘要:查询以 李 开头的 db.student.find({name:/^李/}) 查询英文的 姓名 db.student.find({name:/^[a-zA-Z]{2,10}$/}) 分页 // db.student.find({}).limit(2) skip 起始位置 db.student.fin 阅读全文
posted @ 2019-08-26 16:48 EricBlog 阅读(1636) 评论(0) 推荐(0)
摘要:查询 db.student.find({}) 查询db.student.find({name:"李强1"}) 查询 条件查询 db.student.find({sex:"male",age:{$gte:20}}) 查询返回一条记录 db.student.findOne({}) 表达式 $lt 小于 阅读全文
posted @ 2019-08-26 14:42 EricBlog 阅读(211) 评论(0) 推荐(0)
摘要:切换/创建数据库 use test 添加数据db.student.save({name:"J33ack",age:25}) 查看数据库show dbs 删除当前数据库 db.dropDatabase() 创建集合 db.createCollection("student") 查看集合show col 阅读全文
posted @ 2019-08-26 11:09 EricBlog 阅读(223) 评论(0) 推荐(0)
摘要:use admindb.createUser({ user:"admin", pwd:"abc123456", roles:[{role:"root",db:"admin"}]}) 开启权限认证 在 C:\Program Files\MongoDB\Server\4.0 目录下新建 mongodb. 阅读全文
posted @ 2019-08-26 09:17 EricBlog 阅读(412) 评论(0) 推荐(0)
摘要:https://www.mongodb.com/download-center/community 在服务里 可以启动和关闭服务 net stop "mongodb" net start "mongodb server" 配置环境变量 添加到 path 目录 C:\Program Files\Mon 阅读全文
posted @ 2019-08-23 16:45 EricBlog 阅读(111) 评论(0) 推荐(0)
摘要:from redis_db import poolimport redisimport timecon = redis.Redis( connection_pool=pool)try: # 字符串 # con.set("country", "英国") # con.set("city", "伦敦") 阅读全文
posted @ 2019-08-23 11:05 EricBlog 阅读(191) 评论(0) 推荐(0)
摘要:https://pypi.org/project/redis/ pip install redis 阅读全文
posted @ 2019-08-22 17:57 EricBlog 阅读(262) 评论(0) 推荐(0)
摘要:http://doc.redisfans.com/ 阅读全文
posted @ 2019-08-22 16:27 EricBlog 阅读(138) 评论(0) 推荐(0)
摘要:multi 开启一个事务 set num 0 watch num 监视数据 multi 开启事务 incr num 增加1 incrby num 10 增加10 exec 结束事务 discard 取消事务 阅读全文
posted @ 2019-08-22 16:26 EricBlog 阅读(84) 评论(0) 推荐(0)
摘要:del 删除记录 del keyword exists 判断是否存在某个key exists employee 存在返回 1 否则返回0 expire 设置记录过期时间 expire employee 5 5秒 expireat : 设置记录的过期时间 时间戳 move 把记录迁移到其他逻辑库 mo 阅读全文
posted @ 2019-08-22 16:02 EricBlog 阅读(145) 评论(0) 推荐(0)
摘要:添加 zadd keyword 0 'eric' 0 'zhang' 0 'yun' 查看列表 zrevrange 降序排列 zrevrange keyword 0 -1 增加分数 zincrby keyword 1 'eric' zcard 获取有序集合长度 zcard keyword zcoun 阅读全文
posted @ 2019-08-22 15:10 EricBlog 阅读(169) 评论(0) 推荐(0)
摘要:sadd emptno 8000 sadd emptno 8001 sadd emptno 8002 smembers emptno 返回集合全部数据 scard 获取集合长度 sismember 判断是否含有某个元素 sismember emotno 8000 srem 删除元素 srem emp 阅读全文
posted @ 2019-08-21 18:00 EricBlog 阅读(291) 评论(0) 推荐(0)
摘要:列表 rpush dname 技术部 后勤部 售后部 lpush dname 秘书部 lset dname 2 销售部 修改 lrange dname 0 -1 打印所有列表 llen dname 获取长度 lindex dname 0 获取列表某个元素 linsert 在某个位置插入元素 lins 阅读全文
posted @ 2019-08-21 16:13 EricBlog 阅读(110) 评论(0) 推荐(0)
摘要:哈希 hset 设置哈希表字段 hset 8000 ename tom hset 8000 job salesman hget 8000 ename "tom" hget 获取哈希表字段值 hmget 获取多个哈希表字段值 hgetall 获取所有哈希表字段值 hmset 设置哈希表多个字段 hms 阅读全文
posted @ 2019-08-21 15:27 EricBlog 阅读(340) 评论(0) 推荐(0)
摘要:1 字符串 设置: set key value 获取: get key 删除: del key getrange key 0 3 截取字符串内容 strlen name 获取长度 setex city 5 beijing 设置过期时间 5秒 psetex city 5 beijing 设置过期时间 阅读全文
posted @ 2019-08-21 14:37 EricBlog 阅读(162) 评论(0) 推荐(0)
摘要:下载地址 https://github.com/ServiceStack/redis-windows/tree/master/downloads 安装可视化工具 RedisDesktopManager 参数配置 redis.windows.conf port 6379 端口号 bind 0.0.0. 阅读全文
posted @ 2019-08-21 13:54 EricBlog 阅读(171) 评论(0) 推荐(0)
摘要:pip install colorama 阅读全文
posted @ 2019-08-15 11:02 EricBlog 阅读(365) 评论(0) 推荐(0)
摘要:import mysql.connector.poolingconfig = { "host": "localhost", "port": 3306, "user": "root", "password": "", "database": "demo"}try: pool = mysql.conne 阅读全文
posted @ 2019-08-15 09:55 EricBlog 阅读(535) 评论(0) 推荐(0)
摘要:# python 链接mysqlimport mysql.connector.poolingconfig = { "host":"localhost", "port": 3306, "user" : "root", "password" : "", "database" : "demo"}try: 阅读全文
posted @ 2019-08-14 17:19 EricBlog 阅读(1593) 评论(0) 推荐(0)
摘要:import mysql.connectortry: con = mysql.connector.connect( host="localhost", port="3306", user="root", password="", database="demo" ) con.start_transac 阅读全文
posted @ 2019-08-14 16:56 EricBlog 阅读(489) 评论(0) 推荐(0)
摘要:下载对应版本 安装 https://dev.mysql.com/downloads/connector/python/ 创建链接 阅读全文
posted @ 2019-08-14 16:55 EricBlog 阅读(235) 评论(0) 推荐(0)
摘要:select HEX(AES_ENCRYPT('你好世界','ABC123456')) select AES_DECRYPT(UNHEX('E85A104B6142A7375E53C0545CAD48EE'),'ABC123456') HEX() 二进制转十六进制 UNHEX() 十六进制转 二进制 阅读全文
posted @ 2019-08-09 18:53 EricBlog 阅读(2281) 评论(0) 推荐(0)
摘要:C:\Users\Eric>mysqldump -uroot -p demo->数据库名 > C:\Users\Eric\demo.sql 导出目录地址 导入 sql 文件 mysql> use demoDatabase changedmysql> source C:\Users\Eric\demo 阅读全文
posted @ 2019-08-09 16:54 EricBlog 阅读(93) 评论(0) 推荐(0)
摘要:START TRANSACTION delete from t_emp delete from t_deptcommit START TRANSACTION delete from t_emp delete from t_dept SELECT * FROM t_emp 查询不到数据 SELECT 阅读全文
posted @ 2019-08-09 15:41 EricBlog 阅读(142) 评论(0) 推荐(0)
摘要:-- 绝对值 100select abs(-100)-- 四舍五入 保留两位小数 4.6300select round(4.6288*100)/100 -- 向下取整 9select floor(9.9) -- 向上取整 4select CEIL(3.2) -- 2的3次幂SELECT power( 阅读全文
posted @ 2019-08-09 12:58 EricBlog 阅读(256) 评论(0) 推荐(0)
摘要:# 删除10部门中 工龄超过20年的员工 delete from t_emp where deptno = 10 and DATEDIFF(NOW(),hiredate)/365 >= 20 #删除20部门中工资最高的员工记录 delete from t_emp where deptno = 20 阅读全文
posted @ 2019-08-08 17:32 EricBlog 阅读(191) 评论(0) 推荐(0)
摘要:#把每个员工编号和上司的编号+1,用order by 完成 update t_emp set empno = empno + 1,mgr = mgr + 1 ORDER BY empno DESC # 把月收入前三名的工资减100 LIMIT 完成 UPDATE t_emp set sal = sa 阅读全文
posted @ 2019-08-08 16:12 EricBlog 阅读(690) 评论(0) 推荐(0)
摘要:单条插入 insert into t_dept(deptno,dname,loc)VALUES(50,'技术部','北京') 多条插入 insert into t_dept(deptno,dname,loc)VALUES(60,'后勤部','北京'),(70,'开发部','北京') 子查询插入 in 阅读全文
posted @ 2019-08-08 14:56 EricBlog 阅读(166) 评论(0) 推荐(0)
摘要:1 查询底薪超过公司平均底薪的员工信息? select e.empno,e.ename,e.salfrom t_emp as e join (select avg(sal) as avg from t_emp) t on e.sal > t.avg 2 统计人数 格式化时间 select count 阅读全文
posted @ 2019-08-08 13:30 EricBlog 阅读(561) 评论(0) 推荐(0)
摘要:平均 svg select avg(sal + IFNULL(comm,0)) as avg_sal from t_emp 总和 sum select sum(sal + IFNULL(comm,0)) as sum_sal from t_emp 最大 max select max(sal + IF 阅读全文
posted @ 2019-08-07 17:39 EricBlog 阅读(145) 评论(0) 推荐(0)
摘要:查询语句 select * from t_deptselect empno,ename,sal from t_emp select empno, sal * 12 as "income" from t_emp 分页 select empno,ename from t_emp limit 10,5 去 阅读全文
posted @ 2019-08-07 14:52 EricBlog 阅读(252) 评论(0) 推荐(0)
摘要:def log(func): def wrapper(): print("开始执行") func() print("执行完毕") return wrapperdef log_in(func): def wrapper(): print("开始进入...") func() print("结束...") 阅读全文
posted @ 2019-08-02 17:25 EricBlog 阅读(203) 评论(0) 推荐(0)
摘要:class Cat(): tag = ' 猫科动物 ' def __init__(self, name): self.name = name @staticmethod def breah(): print('需要呼吸空气') @classmethod def show_info(cls, name 阅读全文
posted @ 2019-08-02 14:38 EricBlog 阅读(249) 评论(0) 推荐(0)
摘要:class PetCat(): """ 家猫类""" def __init__(self, name, age): self.name = name # 私有属性 self.__age = age @property def age(self): return self.__age @age.set 阅读全文
posted @ 2019-08-02 11:41 EricBlog 阅读(255) 评论(0) 推荐(0)
摘要:""""""class BaseCat(object): """ 猫科基础类""" tag = '猫科动物' def __init__(self, name): self.name = name def eat(self): print('吃东西')class Tiger(BaseCat): """ 阅读全文
posted @ 2019-08-02 10:10 EricBlog 阅读(174) 评论(0) 推荐(0)
摘要:class Cat(): """ 类 """ tag = '我是家猫' def __init__(self, name, age): self.name = name # 私有变量 self.__age = age def set_age(self, age): self.__age = age # 阅读全文
posted @ 2019-08-02 10:09 EricBlog 阅读(275) 评论(0) 推荐(0)
摘要:def write_file(): """ 文件写入""" file_name = "wri2te_test.txt" # 以写入的方式打开 f = open(file_name,'w') # 写入内容 f.write('hello') # 换行符 f.write('\n') # 写入内容 f.wr 阅读全文
posted @ 2019-08-01 11:27 EricBlog 阅读(9968) 评论(0) 推荐(0)
摘要:def read_file(): """ 读取文件 """ file_name = 'test.txt' # 打开文件 # f = open(file_name, encoding = 'utf-8') with open(file_name, encoding = 'utf-8') as f: # 阅读全文
posted @ 2019-08-01 10:49 EricBlog 阅读(318) 评论(0) 推荐(0)
摘要:## def use_filer(l):## # 过滤偶数# rest = filter(lambda n: n % 2 != 0, l)# return rest## if __name__ == '__main__':# l = [1,2,3,4,5,6,7,8,9,10,11]# rest = 阅读全文
posted @ 2019-08-01 10:14 EricBlog 阅读(296) 评论(0) 推荐(0)