Hi friends, this is Trilochan from Silan Software, BBSR. In this tutorial simple point in python with MySQL that I am presenting, that is we will create a table and show that table by executing python source code. Let’s see in detail:
import mysql.connector
con=mysql.connector.connect(host=’localhost’, user=’root’, password=’silan’)
obj=con.cursor()
obj.execute(“create table customer(cid varchar(200), cname varchar(200), caddress varchar(200))”)
Now we will run this code then customer table will create.
Now we will see the tables in silandb database, then we will run the following code:
If we want to see the customer table in MySQL environment, then open MySQL workbench
import mysql.connector
con=mysql.connector.connect(host=’localhost’, user=’root’, password=’silan’, database=’silandb’)
obj=con.cursor()
obj.execute(“show tables”)
for x in obj:
print(x)
Now we will run this code then we will get all tables in silandb databse. To see in MySQL environment, open MySQL workbench and execute the statement by selecting silandb database that is:
show tables;
now we will get customer table.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc