Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL Server Question
#1
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
Reply
#2
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_exa...t-managers. What package do you use to interact with the DB?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Dispatch from pypiwin32

from win32com.client import Dispatch #pip install pypiwin32
Reply
#4
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/di...mssql.html
if you select to use adodbapi, prerequisite is Hammond's pywin32 - http://adodbapi.sourceforge.net/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to take the tar backup files form remote server to local server sivareddy 0 1,917 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Newbie question for bulk insert into SQL Server database zydjohn 6 12,424 Dec-14-2017, 11:04 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020