In iPython I am using the following code to connect to a SQL server with SQLAlchemy:
import sqlalchemy as sa
import urllib
import pandas as pd
connection_string = "DRIVER={SQL Server};SERVER=myserver;DATABASE=mydatabase;TRUSTEDCONNECTION=Yes"
connection_string = urllib.quote_plus(connection_string)
connection_string = "mssql+pyodbc:///?odbc_connect=%s" % connection_string
engine = sa.create_engine(connection_string).connect()
I am switching over to Beaker notebook because I enjoy its features, but am unsure how to get the SQL cells to connect to the SQL database, as it does above. I know you are supposed to put driver information in the "Default Data Source" box in Language Manager, but if I try to put the connection_string in there it spits an error.
Suggestions?
If you are using docker, you need to mount a volume that is accessible from within the docker machine and you have to be sure that you are able to reach your DB server from within the docker machine.
See the SQL example file in the tutorial notebook for further reference and the image below for a sample configuration