Olá Pessoal, boa tarde.
Estimo que estejam todos bem.
Por gentileza pode me ajudar, quando vou executar empregados = pd.read_sql(query, engine)
Está dando erro.
import sqlalchemy
from sqlalchemy import create_engine, MetaData, Table, inspect
engine = create_engine('sqlite:///:memory:')
url = 'https://raw.githubusercontent.com/alura-cursos/Pandas/main/clientes_banco.csv'
import pandas as pd
dados = pd.read_csv(url)
dados.head()
dados.to_sql('clientes', engine, index=False)
inspector = inspect(engine)
print(inspector.get_table_names())
query = 'SELECT * FROM clientes WHERE Categoria_de_renda="Empregado"'
empregados = pd.read_sql(query, engine)
AttributeError Traceback (most recent call last)
<ipython-input-57-f5ac1724610d> in <cell line: 2>()
1 # empregados = pd.read_sql(query, engine)
----> 2 empregados = pd.read_sql(query, engine)
2 frames
/usr/local/lib/python3.10/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1403 def execute(self, *args, **kwargs):
1404 """Simple passthrough to SQLAlchemy connectable"""
-> 1405 return self.connectable.execution_options().execute(*args, **kwargs)
1406
1407 def read_table(
AttributeError: 'OptionEngine' object has no attribute 'execute'
Obrigado!