当前位置:Gxlcms > 数据库问题 > Python MySQL - 创建/查询/删除数据库

Python MySQL - 创建/查询/删除数据库

时间:2021-07-01 10:21:17 帮助过:23人阅读

coding=utf-8 import mysql.connector import importlib import sys #连接数据库的信息 mydb = mysql.connector.connect( host=115.xx.10.121, port=3306, user=root, password=xxxxxZ6XPXbvos, ) mycursor=mydb.cursor() #创建数据库 mycursor.execute(create database test_cc) #查询数据库 mycursor.execute(show databases) for x in mycursor: if test_cc in x: print 成功 #删除数据库 mycursor.execute(drop database test_cc)

 

Python MySQL - 创建/查询/删除数据库

标签:0.12   int   xxxx   importlib   nec   数据   use   创建   style   

人气教程排行