Why not something like:
fh = open(myfile,"r")
db = MySQL.connect(foo)
c=db.cursor()
while 1:
if not line():
imdone()
else:
try:
c.execute(fh.readline())
except MySQLError:
someerrorhandling()
Maybe this isn't what you are after?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was interested in taking some
raw SQL files and executing them,
something like:
db=MySQL.connect(...)
c=db.cursor()
c.execute("""use mydb; select * from mytable;""")
(which could easily be:
commands= open("rawsql","r").read()
c.execute(commands)
if it would work).
Why not something like:
fh = open(myfile,"r")
db = MySQL.connect(foo)
c=db.cursor()
while 1:
if not line():
imdone()
else:
try:
c.execute(fh.readline())
except MySQLError:
someerrorhandling()
Maybe this isn't what you are after?
A bit tired, it should of course be:
...
...
c=db.cursor()
while 1:
line = fh.readline()
if not line:
imdone()
else:
try:
c.execute(line)
except MySQLError:
someerrorhandling()