Reputation: 71
Good Afternoon, I wrote a query in MySQL, and I want to execute the same query in Python. The Code I wrote as Follows. 1.
import mysql.connector
from mysql.connector import Error
try:
connection = mysql.connector.connect(host='localhost',
database='AdventureWorks2012',
user='root',
password='r@#*****')
sql_select_Query = "select * from Person.person"
cursor = connection.cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchall()
However, I'm getting following error message while running part two- ''File "", line 5 password='r@#*****') ^ SyntaxError: unexpected EOF while parsing''
Any suggestion please how to overcome this problem?
Upvotes: 0
Views: 356
Reputation: 1427
You are missing the except
clause:
try:
connection = mysql.connector.connect(host='localhost',
database='AdventureWorks2012',
user='root',
password='r@#*****')
except Exception as e:
print(e)
You should check the documentation
for more information.
Upvotes: 1