Reputation: 622
I connect to a database in MS Access using SQL Alchemy:
import urllib
from sqlalchemy import inspect
from sqlalchemy import create_engine
connection_string = (
r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
r'DBQ=C:/Users/mvideo/Desktop/dataBase.accdb;'
r'ExtendedAnsiSQL=1;'
)
connection_uri = f"access+pyodbc:///?odbc_connect={urllib.parse.quote_plus(connection_string)}"
engine = create_engine(connection_uri)
print (engine.table_names())
THe result is
['Air', 'regions', 'Soil', 'water']
I get names of all tables. I want to get query from on of this table (with name of water
). How should I solve my problem?
Upvotes: 1
Views: 1323
Reputation: 24
from sqlalchemy import text
t = text("SELECT * FROM water")
connection = engine.connect()
result = connection.execute(t)
Upvotes: 0