MySQL connection syntax with example
Answers
Answered by
0
Answer:
The command goes like:
#import connector module
import mysql.connector
#assigning database to work on
mydb=mysql.connector.connect ( host="localhost", user="username", passwd="yourpassword", database="database" )
#assigning sursor object
mycursor=mydb.cursor ()
#giving command
mycursor.execute ( "create table employee ( roll int, name varchar (20) , age int )" )
#executing the command
mydb.commit ()
#get an output for satisfaction
print ( mycursor.rowcount, "records made" )
Similar questions