Menu

c.execute("source file.sql;") not working?

emaneri
2006-08-30
2012-09-19
  • emaneri

    emaneri - 2006-08-30

    from the MySQL command line

    source file.sql;

    works as expected.
    from a python shell,

    c.execute("source file.sql;")

    gives me the error message

    (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source process_new_students_temp.sql' at line 1")

    any ideas?
    thanks-
    erin

     
    • Mario Frasca

      Mario Frasca - 2006-08-31

      On 2006-0830 14:47:15, SourceForge.net wrote:
      > c.execute("source file.sql;")
      > [...]
      > any ideas?

      if all you need is execute an sql script from python, you may consider using the function parseSql, contained in the ibo3 module to be found on http://sourceforge.net/projects/ibo

      maybe there are better tools doing the same, this one works (for me)...

      use it like this:

      import ibo3
      [c.execute(i) for i in ibo3.parseSql('file.sql')]

      > thanks-

      HTH,

      Mario

      p.s.:
      bugreports welcome.

       
    • Andy Dustman

      Andy Dustman - 2006-08-30

      source is not actually an SQL statement but instead a built-in feature of the command-line client.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.