Menu

using 'source [file]' through mysqldb

Help
2006-09-28
2012-09-19
  • Jack Andrews

    Jack Andrews - 2006-09-28

    hi,

    this script:

    fn='mysqlcommands.txt'
    db=my.connect(user='root',passwd='mysql')
    cr=db.cursor()
    def mye(c):cr.execute(c)
    mye('drop database if exists tmp')
    mye('create database tmp')
    mye('use tmp')
    mye("source %s"%fn)

    fails. isn't 'source' legal mySQL?

    the traceback:

    File "a.py", line 213, in cb
    mye("source mysqlcommands.txt")
    File "a.py", line 209, in mye
    cr.execute(c)
    File "c:\python24\lib\site-packages\MySQLdb\cursors.py", line 163, in execute
    self.errorhandler(self, exc, value)
    File "c:\python24\lib\site-packages\MySQLdb\connections.py", line 35, in defau
    lterrorhandler
    raise errorclass, errorvalue
    _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax
    ; check the manual that corresponds to your MySQL server version for the right s
    yntax to use near 'source mysqlcommands.txt' at line 1")

    thanks,

    jack

     
    • Andy Dustman

      Andy Dustman - 2006-09-28

      No, source is not valid SQL. It's something locally-interpreted by the mysql commmand-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.