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


#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')

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM