Skip to content

Commit 517e60c

Browse files
authored
Connect MySQL Databses in Python3
Connect MySQL Databses in Python3
1 parent b84eaea commit 517e60c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

MySQL_Databses.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import mysql.connector
2+
3+
4+
# MySQl databses details
5+
6+
mydb = mysql.connector.connect(
7+
host="localhost",
8+
user="root",
9+
passwd="",
10+
database="db_name"
11+
)
12+
mycursor = mydb.cursor()
13+
14+
15+
16+
#Execute SQL Query =>>>> mycursor.execute("SQL Query")
17+
mycursor.execute("SELECT column FROM table")
18+
19+
myresult = mycursor.fetchall()
20+
21+
for x in myresult:
22+
print(x)

0 commit comments

Comments
 (0)