一、正则的复习
1、[^}]* 不是}这个符号的0个或者多个
2、<html>hello world </html> 正则的写法 (?P<tag>\w+)>(.*)</(?P=tag)>
3、非贪婪匹配 .*?
4、匹配字幕 [a-zA-Z] 匹配数字 \d
5、^[] 与 [^] 的区别
二、数据库 MySQL
1、Python的 DB-API 为大多数数据库提供了接口。使用流程为:①引入API模块;②获取与数据库的连接;③执行SQL语句和存储过程;④关闭数据库连接。
2、Python 3 安装MySQL数据库软件:使用 pip install pymysql
3、mysql 的事物:
事务是必须满足4个条件(ACID): Atomicity(原子性)、Consistency(稳定性)、Isolation(隔离性)、Durability(可靠性)。
①事务的原子性:一组事务,要么成功;要么撤回。例如一次处理200个事物,有一个失败,就会撤回该任务。
②稳定性 : 有非法数据(外键约束之类),事务撤回。
③隔离性:事务独立运行。一个事务处理后的结果,影响了其他事务,那么其他事务会撤回。事务的100%隔离,需要牺牲速度
④可靠性:软、硬件崩溃后,InnoDB数据表驱动会利用日志文件重构修改。可靠性和高速度不可兼得, innodb_flush_log_at_trx_commit选项 决定什么时候吧事务保存到日志里。
4、推荐的MySQL插件:方便连接各种数据库。
5、授权超级用户 with grant option
例如grant all privileges on *.* to 'tangnanbing'@'%' identified by '1qaz@WSX' with grant option
6、查看库 show datebase
7、查看都有哪些库 show datebases
8、查看某个库的表 use db;show tables \G;
9、查看表的字段 desc tb;
查看建表语句 show create table tb;
当前是哪个用户 select user();
当前库 select database();
创建库 create database db1;
创建表 create table t1 (id int, name char(40) adress varchar(30));
查看数据库版本 select version();
查看mysql状态 show status;
修改mysql参数 show variables like 'max_connect%'; set global max_connect_errors = 1000;
查看mysql队列 show processlist;
10、创建普通用户并授权 grant all on *.* to databases1.user1 identified by '123456';
grant all on db1.* to 'user2'@'10.0.2.100' identified by '111222';
grant all on db1.* to 'user3'@'%' identified by '231222';insert into tb1 (id,name) values(1,'aming');
11、更改密码UPDATE mysql.user SET password=PASSWORD("newpwd") WHERE user='username' ;
12、查询 select count(*) from mysql.user; select * from mysql.db;
select * from mysql.db where host like '10.0.%';
13、插入 update db1.t1 set name='aaa' where id=1;
清空表 truncate table db1.t1;
删除表 drop table db1.t1;
删除数据库 drop database db1;
修复表 repair table tb1 [use frm];
14、查看权限show grants for root@'localhost';
三、MySQL的连接(及常用参数)