Article 5DPG2 Write python mariadb qurey in lines?

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= serverlatest?d=yIl2AUoC8zA latest?i=8d9CpaEPGJ8:E-r3g5yttnI:F7zBnMy latest?i=8d9CpaEPGJ8:E-r3g5yttnI:V_sGLiP latest?d=qj6IDK7rITs latest?i=8d9CpaEPGJ8:E-r3g5yttnI:gIN9vFw8d9CpaEPGJ8
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments