python 3.8.10 mysql8.0.32 win7-64
代码如下:
from sqlalchemy import text
import pandas as pd
import mysql.connector
from sqlalchemy import create_engine
engine = create_engine("mysql+mysqlconnector://root:*********@/test_db")
connection = engine.connect()
sql='source D:/学习/测试数据/ONUdata/creatviews.sql;'
connection.execute(text(sql))
print("视图建立成功!!!")
```上面的sql语句在mysql命令行执行是成功的,但是在python中使用就会报错
_mysql_connector.MySQLInterfaceError: 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 D:/学习/测试数据/ONUdata/creatviews.sql' at line 1
这个问题怎么解决呢?