How to connect to MS SQL Server database remotely by IP in Python using mssql and pymssql
<p>How can I connect to MS SQL Server database remotely by IP in Python using mssql and pymssql modules.
To connect locally I use link = mssql+pymssql://InstanceName/DataBaseName</p>

<p>I enabled TCP/IP Network Configurations. 
But How can I get the connection link?</p>

<p>Thank you.</p>

<p>You need to create a <code>Connection</code> object</p>

<pre><code>import pymssql
ip = '127.0.0.1'
database_connection = pymssql.connect(host=ip, port=1433, username='foo', password='bar')
</code></pre>

<p>If you're using SQLAlchemy, or another ORM that supports connection strings, you can also use the following format for the connection string.</p>

<pre><code>'mssql+pymssql://{user}:{password}@{host}:{port}'
</code></pre>

python sql-server pymssql