Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#102 executing scripts with sqlite backend

closed-invalid
nobody
None
5
2009-12-31
2009-10-21
Matt Domsch
No

When trying to execute a multi-line sql script using sqlobject-admin upgrade, sqlobject fails

Traceback (most recent call last):
File "/usr/bin/tg-admin", line 8, in <module>
load_entry_point('TurboGears==1.0.8', 'console_scripts', 'tg-admin')()
File "/usr/lib/python2.5/site-packages/turbogears/command/base.py", line 400, in main
command.run()
File "/usr/lib/python2.5/site-packages/turbogears/command/base.py", line 138, in run
command.the_runner.run(sys.argv)
File "/usr/lib/python2.5/site-packages/sqlobject/manager/command.py", line 101, in run
runner.run()
File "/usr/lib/python2.5/site-packages/sqlobject/manager/command.py", line 307, in run
self.command()
File "/usr/lib/python2.5/site-packages/sqlobject/manager/command.py", line 1191, in command
conn.query(sql)
File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 337, in query
return self._runWithConnection(self._query, s)
File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 250, in _runWithConnection
val = meth(conn, *args)
File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 334, in _query
self._executeRetry(conn, conn.cursor(), s)
File "/usr/lib/python2.5/site-packages/sqlobject/sqlite/sqliteconnection.py", line 197, in _executeRetry
raise Warning(ErrorMessage(e))
sqlobject.dberrors.Warning: You can only execute one statement at a time.

However, for updating database schemas, I need to be able to execute more than one statement at a time.

Patch attached looks at the query string for multiple lines, and if so, calls executescript() instead of execute().

Discussion

  • Matt Domsch
    Matt Domsch
    2009-10-21

    sqlobject-sqlite-executescript.patch

     
    Attachments
  • Oleg Broytman
    Oleg Broytman
    2009-12-14

    I am not sure how to accept the patch. First, shouldn't SQL statements be separated by a semicolon (';'), not a eoln? Second, isn't SQLiteConnection too low-level for the patch? Shouldn't it be fixed somewhere higher so any backend can accept mutlistatment script?

     
  • Oleg Broytman
    Oleg Broytman
    2009-12-31

    • status: open --> closed-invalid