I have the following line of code that keeps giving me an error that Engine object has no object execute. I think I have everything right but no idea what keeps happening. It seemed others had this issue and restarting their notebooks worked. I'm using Pycharm and have restarted that without any resolution. Any help is greatly appreciated!
import pandas as pd
from sqlalchemy import create_engine, text
import sqlalchemy
import pymysql
masterlist = pd.read_excel('Masterlist.xlsx')
user = 'root'
pw = 'test!*'
db = 'hcftest'
engine = create_engine("mysql+pymysql://{user}:{pw}@localhost:3306/{db}"
.format(user=user, pw=pw, db=db))
results = engine.execute(text("SELECT * FROM companyname;"))
for row in results:
print(row)
engine.connect(). It's lazy and won't actually connect until neededwith engine.connect() as conn: