0
sqlalchemy create_engine函數在從文件運行時不工作,但它在python shell中正常工作,因此找不到問題。所以請有人指出這個問題。我是用戶窗口10和python版本3.5.3。sqlalchemy create_engine函數在運行文件名時不工作testalchemy.py
以下是錯誤在運行腳本文件:
C:\python\python.exe C:/Users/Lenovo/Desktop/Auto/pythonseltest/Tests/sqlalchemy.py Traceback (most recent call last): File "C:/Users/Lenovo/Desktop/Auto/pythonseltest/Tests/sqlalchemy.py", line 2, in <module>
from sqlalchemy import create_engine File "C:\Users\Lenovo\Desktop\Auto\pythonseltest\Tests\sqlalchemy.py", line 2, in <module>
from sqlalchemy import create_engine ImportError: cannot import name 'create_engine'
Process finished with exit code 1
下面是實際的代碼
from sqlalchemy import create_engine
engine =create_engine('mysql+mysqldb://username:[email protected]:3306/databasename')
connection = engine.connect() result = connection.execute('select *
from cuser')
此代碼的工作很好,如果我通過線在Python Shell鍵入此行代碼,但同時嘗試運行該文件它顯示以上錯誤。
感謝它的工作。 – user7604331
Thx。我遇到了完全相同的問題。我的文件與播放具有相同的名稱。 Stoopid我。 – Semo