1、创建mysql数据库及表;
mysql> create table test_emp1 (id INT(12),name VARCHAR(25),deptid INT(12),salary FLOAT);
Query OK, 0 rows affected (0.06 sec)
插入数据:
mysql> insert into test_emp1(id,name,deptid,salary) values (001,'wang','001',80000);
Query OK, 1 row affected (0.01 sec)
2、python3.7操作mysql数据库增删改查
https://www.cnblogs.com/UncleYong/p/10938993.html
(1)连接数据库并查表中的数据输出。
import pymysql
conn=pymysql.connect(
host='10.1.33.203',
port=3306,
user='root',
password='123456',
db='test',
charset='utf8'
)
cursor=conn.cursor()
sql='select * from test_emp1'
print('%s',sql)
rows=cursor.execute(sql)
print(cursor.fetchone())
cursor.close()
conn.close()
if rows>=0:
print('连接成功;')
else:
print('连接失败;')