当前位置:网站首页>Create database instance

Create database instance

2022-06-11 16:53:00 A pig that dotes on Nannan

from pymysql import *
#  Create a database instance 
# 1. Establish a database connection 
conn = connect(host="192.168.134.101",user="root",password="123456")
# 2. Get cursor object 
mycur = conn.cursor()
# 3. Create a database instance , And back to int Result of type ,1 Indicates successful addition , If the database instance already exists , Throw an exception 
try:
    result = mycur.execute("create database pydb")
    print(" The result returned after adding the database instance :",result)
except ProgrammingError as msg:
    print(" Exception occurred while adding database instance :",msg)
finally:
    # 4. Close cursor 
    mycur.close()
    # 5. Close the connection 
    conn.close()

 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[A pig that dotes on Nannan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011927002619.html