create database studydb;
use studydb;
create table userinfo(
id int primary key auto_increment,
user char(12),
password char(32)
);
insert into userinfo value(1,'mike','3714');
python 代码
import pymysql
user = input('username:')
pwd = input('password:')
conn = pymysql.connect(host='127.0.0.1',
user='root',
password='123456',
database='studydb')
sql = 'select * from userinfo where user = %s and password = %s;'
cur = conn.cursor()
cur.execute(sql,user,pwd)
print(cur.fetchone())