The python link database needs to download a plugin
The following address is only 32-bit 64-bit and other addresses are required
https://sourceforge.net/projects/mysql-python/#
database link code
import MySQLdb
conn = MySQLdb.Connect(
host = '127.0.0.1',
port = 3306,
user = 'root',
passwd = 'root',
db = 'test',
charset = 'utf8'
)
print conn
#Link successfully printed
<_mysql.connection open to '127.0.0.1' at 26a3be8>
#Write query statement
# get cursor
cursor = conn.cursor()
#Cursor execute query statement
cursor.execute('select * from users limit 100')
#python query will enter the buffer after getting the data, and extract the data from the buffer
result =cursor.fetchall()
for row in result:
print row