![]() |
how to connect mysql from txt 1 line goes good but not all lines in text - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to connect mysql from txt 1 line goes good but not all lines in text (/thread-33028.html) |
how to connect mysql from txt 1 line goes good but not all lines in text - kingceasarr - Mar-23-2021 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 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)
RE: how to connect mysql from txt 1 line goes good but not all lines in text - Larz60+ - Mar-23-2021 duplicate post same as: https://python-forum.io/Thread-Need-Help-with-connecting-to-mysql-from-txt-file RE: how to connect mysql from txt 1 line goes good but not all lines in text - kingceasarr - Mar-24-2021 hii i dont understand what you meant brother and is it normal i cant msg you? any good good site for tut on python? and i have now made small changes to my dbs connect file can you look at it for me and in small explain to me that if the program connects or not how continue to last dbs in opend file and not stop after check one import MySQLdb import MySQLdb._exceptions import sys, os, requests with open("datafile.txt", "r") as lijst: for line in lijst: lijst.readline connection = eval('MySQLdb.connect({})'.format(lijst.readline().strip())) print(connection)
RE: how to connect mysql from txt 1 line goes good but not all lines in text - Larz60+ - Mar-24-2021 Instead of creating a new thread on same subject, you should just add new posts to same thread. It just keeps things neat and avoids confusion. Please read: https://python-forum.io/misc.php?action=help&hid=22 RE: how to connect mysql from txt 1 line goes good but not all lines in text - buran - Mar-24-2021 I locked the other thread. Keep the discussion here. I decided not to merge threads because it will create even bigger confusion. |