Ok so here is my use case. I've to make connection to different types of DB(MSSQL, oracl, MYSQL, etc.). I've .sql files for each of these database. As it seems sqlalchemy can't run .sql file so we need to open and execute the statements one by one from the .sql files over the connection.
So guys, I'm having this information and I wanted to connect using SQL Alchemy.
<db type="MSSQL" version="2005" patch_level="SP2" port="1433" id="MSSQLSERVER"/>
here MSSQLServer is the instance. No DB information is provide. so do I need DB name to connect to DB?
this is my command
engine = create_engine('mssql+pyodbc://sa:pass@172.21.153.227/MSSQLSERVER', echo=True)
this is my complete code
from sqlalchemy.engine import create_engine
engine = create_engine('mssql+pyodbc://sa:pass@172.21.153.227', echo=False)
connection = engine.connect()
connection.execute(
"""
select @@version
"""
)
connection.close()