Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Wednesday, December 2, 2020

SQL Queries for Integrate SQL with Python by importing the MySQL module by G Krishna Chauhan

Source Code

 MySQL Connector

import mysql.connector


Create Connection:

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

print(mydb)


Creating a Database:

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

mycursor = mydb.cursor()

mycursor.execute("CREATE DATABASE mydatabase")



.


No comments:

Post a Comment