Write python mariadb qurey in lines?
by shams from LinuxQuestions.org on (#5DPG2)
This is python code, query the table pop form mariadb and writing the three columns of each row to a file in one line with comma separated:
Code:cur = conn.cursor()
query = "SELECT user, passwd, server FROM pop"
cur.execute(query)
for idx, row in enumerate(cur, start=1):
with open(f'mail{idx}.txt', 'w') as f:
f.write(','.join(row))I want to write the each row to file in three lines like this:
Code:User= user
pssword= passwd
server= server


Code:cur = conn.cursor()
query = "SELECT user, passwd, server FROM pop"
cur.execute(query)
for idx, row in enumerate(cur, start=1):
with open(f'mail{idx}.txt', 'w') as f:
f.write(','.join(row))I want to write the each row to file in three lines like this:
Code:User= user
pssword= passwd
server= server