Home >Backend Development >PHP Tutorial >[Newbie asking for help] Why does pymysql report an EOF error when linking to the database?
1. An error occurred when using pymysql to connect to the database
Error code:
<code>SyntaxError: unexpected EOF while parsing Process finished with exit code 1 </code>
2. Below is my code
<code>import pymysql ## 链接数据库 connection = pymysql.connect(host = 'localhost',user = 'root',passwd = 'gangan',db = 'qiandao') try: cur = connection.cursor() cur.execute("SELECT fk_si_user,si_trueName from fbl_stuinfo where si_trueName like '甘%'") data = cur.fetchall() for row in data: print('%s\n%s'%row) cur.close() connection.commit() </code>
3.What does the EOF error mean? What are the general solutions? Python 3.5 newbie needs advice
1. An error occurred when using pymysql to connect to the database
Error code:
<code>SyntaxError: unexpected EOF while parsing Process finished with exit code 1 </code>
2. Below is my code
<code>import pymysql ## 链接数据库 connection = pymysql.connect(host = 'localhost',user = 'root',passwd = 'gangan',db = 'qiandao') try: cur = connection.cursor() cur.execute("SELECT fk_si_user,si_trueName from fbl_stuinfo where si_trueName like '甘%'") data = cur.fetchall() for row in data: print('%s\n%s'%row) cur.close() connection.commit() </code>
3.What does the EOF error mean? What are the general solutions? Python 3.5 newbie needs advice
You should post all the errors. This error is not necessarily because mysql cannot be connected, it is most likely a problem with your print
print(r'%sn%s'%row) try adding an r in front of it