Often by the financial call to unlock, headache, to remote to the server, open the slow SQL 2005 manager to replicate two unlocked tasks, things a busy will forget, inevitably be a second reminder, the online download of the removal of the lock tool seems to be used in the "Chang Jie Tong t6,t3" on, U8 can not be used. Just want to make a small script or program, think of a codematic before the SQL statement can be automatically born into C # code. You can open the software and find out how to create a new project and compile for C #.
Think of the online said "a function, with C to write, may be 100 lines, with Java to 20 lines, and Python only need 5 lines" then use Python to try to glue these two SQL statements.
To connect with SQL Server first, you need to use a handy "pymssql" with the additional wheels.
Installation method: 1. Direct search pymssql Download source code, compile, first hint PIP version old, perform python-m pip install--upgrade pip upgrade to 8.1, or error. Had to give up
2. Install with ready-made WHL package. :http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql
After the download is complete, use CMD to switch to the download directory statement as follows: (where the Windows environment, switch the directory of different drive characters, need to add "\d" parameter)
CD \d D:\Program\Code\Python\pymssql-master
And then execute
Pip Install PYMSSQL-2.1.2-CP35-CP35M-WIN_AMD64.WHL
After the installation is complete: 650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/3E/wKioL1cXb-uQDkPWAANROUa7vQo905.jpg "title=" 360-41081109.jpg "alt=" Wkiol1cxb-uqdkpwaanroua7vqo905.jpg "/>
There is a ready-made case on the Internet: http://blog.csdn.net/wanzhuan2010/article/details/18844789
Slightly rewritten the next
Import Pymssqlconn = Pymssql.connect (host= ' 192.168.0.0 ', user= ' sa ', password= ' Bugeinikan ', database= ' ufdata_001_2016 ') cur=conn.cursor () #获取游标对象 sql= ' delete from Ufsystem.dbo.ua_task ' Cur.execute (SQL) #执行删除表 (above) cur=conn.cursor () # Gets the cursor object sql= ' delete from Ufsystem.dbo.ua_tasklog ' Cur.execute (SQL) #执行删除表 (above) # #提交事务, no commit is performed, data insertions do not take effect Conn.commit () # # Close the database connection Conn.close
After execution, use SQL Tracker to view statement submission on server side
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/3E/wKioL1cXcebAQlbiAAYBagw49TQ466.jpg "title=" 360-41581546.jpg "alt=" Wkiol1cxcebaqlbiaaybagw49tq466.jpg "/>
Script to clear U8 system document lock written in Python