SQL Server Question - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: SQL Server Question (/thread-13437.html) |
SQL Server Question - EricALionsFan - Oct-15-2018 When closing out of a instance of SQL Server, do I need to destroy the instance or is closing enough? #Close the connection rst.Close() cn.Close() rst = None cn = None RE: SQL Server Question - buran - Oct-15-2018 Closing is enough, garbage collector will do the rest. However it's better to use with context manager and it will close connection for you e.g. http://pymssql.org/en/stable/pymssql_examples.html#using-the-with-statement-context-managers. What package do you use to interact with the DB?
RE: SQL Server Question - EricALionsFan - Oct-15-2018 Dispatch from pypiwin32 from win32com.client import Dispatch #pip install pypiwin32 RE: SQL Server Question - buran - Oct-15-2018 pypiwin32? That's strange choice. Not sure how actively developed it is. Also no docs. It's not Mark Hammond's popular pywin32 package. More like old fork. If I were you I would consider some other packages -pymssql, pyodbc, etc. Also look at sqlalchemy - https://docs.sqlalchemy.org/en/latest/dialects/mssql.html if you select to use adodbapi, prerequisite is Hammond's pywin32 - http://adodbapi.sourceforge.net/ |