Created
October 29, 2013 05:44
-
-
Save jinjie/7209632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sqlite3 as lite | |
import sys | |
con = None | |
try : | |
con = lite.connect(<Sqlite file>) | |
con.row_factory = lite.Row | |
cur = con.cursor() | |
cur.execute('SELECT * FROM ZABCDNOTE WHERE ZTEXT LIKE \'%HTCData%\';') | |
rows = cur.fetchall() | |
for row in rows : | |
start = row["ZTEXT"].index("<HTCData>") | |
end = row["ZTEXT"].index("</HTCData>") | |
if end > start : | |
cur.execute("UPDATE ZABCDNOTE SET ZTEXT = ? WHERE Z_PK = ?", ( | |
row["ZTEXT"].replace(row["ZTEXT"][start:end+10], ''), | |
row["Z_PK"] | |
)) | |
con.commit() | |
print "Updated %d" % cur.rowcount | |
except lite.Error, e : | |
print "Error %s:" % e.args[0] | |
sys.exit(1) | |
finally : | |
if con : | |
con.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment