Python Forum
How can I run sql file in python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I run sql file in python?
#7
this is whay I was missing
subprocess.run(f"mysql -u {user} -p {dbname} < {sqlfile}", shell=True)
thanks !

do you know how can I get the output? meaning if there was a problem or its OK?
this output for example? (this is what I got from my mysql workbanch)
13:38:45	update routers.router set ROU_IP='6.6.7.8' where (ROU_ID='5213' and com_id ='1')	1 row(s) affected Rows matched: 1  Changed: 1  Warnings: 0	0.062 sec
Thanks,
Reply


Messages In This Thread
How can I run sql file in python? - by korenron - Aug-15-2022, 01:39 PM
RE: How can I run sql file in python? - by korenron - Aug-18-2022, 06:09 AM
RE: How can I run sql file in python? - by korenron - Aug-18-2022, 08:42 AM
RE: How can I run sql file in python? - by korenron - Aug-18-2022, 10:37 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020