Subject | Re: [firebird-python] execute a whole script |
---|---|
Author | Philippe Makowski |
Post date | 2014-05-14T09:51:29Z |
Hi,
and do something like :
f = open('tabledefinition.sql')
full_sql = f.read()
sql_commands = full_sql.split('§')
for sql_command in sql_commands:
if sql_command == 'COMMIT':
myconnection.commit()
else:
myconnection.execute_immediate(sql_command)
you got the idea
> I've got a whole script full of SQL for Firebird that I want to executecertainly,
> from python with fdb. Is there a way?
>
> The sqlite3 module has an 'executescript' extension for this.we don't, but feel free to help to write it ;)
>
> Any suggestions?just format your script in a way it can be splitted, using for example '§'
>
and do something like :
f = open('tabledefinition.sql')
full_sql = f.read()
sql_commands = full_sql.split('§')
for sql_command in sql_commands:
if sql_command == 'COMMIT':
myconnection.commit()
else:
myconnection.execute_immediate(sql_command)
you got the idea