Mar-23-2021, 06:06 PM
(This post was last modified: Mar-26-2021, 12:03 AM by kingceasarr.)
hii once again i need help i'm taking courses but just need a little help.
I have a made script that opens a file with data stored to read the file and connect to the database from out that txt file with eval
but now it opens and and start checken and it opens connection at first 3 lines in txt but it connects and print the 4 database in text
I have a made script that opens a file with data stored to read the file and connect to the database from out that txt file with eval
but now it opens and and start checken and it opens connection at first 3 lines in txt but it connects and print the 4 database in text
filepath = 'Results/sorted.txt' with open(filepath) as lijst: for line in lijst: cnt = 1 while line: try: connection = eval('MySQLdb.connect({})'.format(line.strip())) print("Line {}: {}".format(cnt, connection, line.strip())) line = lijst.readline() cnt += 1 while cnt == + 1: connection(cnt, line) except Error as e: print(e)
Error:C:\Users\Gebruiker\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Gebruiker/Downloads/V1/test.py
Line 1: <_mysql.connection open to 'first line' at 0000026EB9D29640>
Line 2: <_mysql.connection open to 'second line' at 0000026EB9DB3FC0>
Line 3: <_mysql.connection open to 'third line' at 0000026EB9D29640>
(2002, "Can't connect to MySQL server on 'fourth line' (10060)")
(2002, "Can't connect to MySQL server on 'fourth line ' (10060)")
(2002, "Can't connect to MySQL server on 'fourth line' (10060)")