1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| """ 一、python实现用户登陆
1、连接、关闭(游标) execute():SQL注入 101.34.178.236:matt:1230 """ import pymysql
ip = "localhost" user = 'root' pwd = '1234'
db = pymysql.connect(ip, user, pwd, "matt")
cursor = db.cursor()
cursor.execute("show databases;")
data = cursor.fetchone()
print("Database version : %s " % data)
db.close()
|