My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 370: Drop database failed
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by s961...@gmail.com, Jun 12, 2014
What steps will reproduce the problem?
1.Drop database by pyodbc

What is the expected output? What do you see instead?
Expect that SQL database to be dropped but it's not.
(Error:42000', '[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot drop database "db_mydatabase" because it is currently in use. (3702) (SQLExecDirectW)')

I tried SQL management studio GUI to drop the database and it works.

What version of the product are you using? On what operating system?
pyodbc-3.0.7.win32-py2.7.exe / Windows Server 2008 R2

Please provide any additional information below.

ConnectionStr='DRIVER={SQL Server};SERVER='+SQLserverIP+';DATABASE='+DATABASE_name+';UID='+UID+';PWD='+PWD

sqlconn=pyodbc.connect(ConnectionStr,autocommit=True)
cur=sqlconn.cursor()
cur.execute("DROP DATABASE "+ DATABASE_name)
sqlconn.close()
Jun 12, 2014
#1 s961...@gmail.com
I have fix it, it was my mistake.

I should establish the connection with master database, not the target database.

Thanks for yor help.

Powered by Google Project Hosting