Monthly Archive: October 2011

Oct 12

How can I delete records from MS SQL Server database using Python?

The following code will delete all records from table in database on server. import win32com.client connectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=database;Data Source=server;" query = "delete from table;" con = win32com.client.Dispatch(‘ADODB.Connection’) con.Open(connectionString) con.Execute(query) con.Close( ) Note: This code works on Windows only. You will also need to install excellent Python for Windows extensions (pywin32) by …

Continue reading »