Sep-09-2023, 05:12 AM
Greetings!
I'm connecting to a DB and can get all the tables from it. No errors
I wanted to find a table named "ToolHistory" and later some other tables and then use pandas DF and filter some rows from the table/tables.
Here is what I got so far:
Thank you.
I'm connecting to a DB and can get all the tables from it. No errors
I wanted to find a table named "ToolHistory" and later some other tables and then use pandas DF and filter some rows from the table/tables.
Here is what I got so far:
conn = pyodbc.connect('DRIVER={SQL Server};SERVER=SomeServer.com,1433;DATABASE=QQS;UID=me;PWD=allgetlost')
cursor = conn.cursor()
for row in cursor.tables():
print(f" >> {row.table_name}")
sql_query = 'SELECT * FROM ToolHistory'
df = pd.read_sql(sql_query, conn)
# tb_one = row.table_name
# if tb_one == 'ToolHistory' :
# print('Found Table ->',tb_one)
#df = pd.read_sql_table('tb_one', conn)
#df = pd.read_sql_table('tb_one', cursor)I cannot pass the line after the print(f" >> {row.table_name}")Any help is appreciated.Thank you.
