Can't get MySQL source query to work using Python mysqldb module

前端 未结 5 1915
情深已故
情深已故 2021-01-02 20:20

I have the following lines of code:

sql = \"source C:\\\\My Dropbox\\\\workspace\\\\projects\\\\hosted_inv\\\\create_site_db.sql\"
cursor.execute (sql)
         


        
5条回答
  •  一整个雨季
    2021-01-02 20:39

    I believe the "source" command is specific to the mysql shell executable - it is not an sql command and cannot be interpreted correctly when executed as an sql statement.

    To achieve your goal, you probably need to read your script file and parse it into individual sql statements, then execute them one at a time with your cursor.

提交回复
热议问题