码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2018-11-14 14:14:58      阅读:166      评论:0      收藏:0      [点我收藏+]

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

#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   

原文地址:https://www.cnblogs.com/chengchengla1990/p/9957126.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!