'How to use dsn.ini file for odbc connection?

I am trying to connect to the msserver using odbc connection using ipython-sql magic in jupyter notebook.

I was wondering how to use dsn.ini file to load the configuration and connect to the server.

References:

My dsn.ini file

[DB_Practice]
username=sa
password=myrealpassword
host=myoriginalservername
drivername=ODBC Driver 17 for SQL Server
database=Practice

Error

%load_ext sql
%config SqlMagic.dsn_filename='./dsn.ini'
%sql --section DB_Practice


Environment variable $DATABASE_URL not set, and no connect string given.
Connection info needed in SQLAlchemy format, example:
               postgresql://username:password@hostname/dbname
               or an existing connection: dict_keys([])

Question

How to connect to msserver using odbc and using dsn.ini file?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source