Skip to content

Instantly share code, notes, and snippets.

Created October 2, 2012 05:55
Show Gist options
  • Save anonymous/3816521 to your computer and use it in GitHub Desktop.
Save anonymous/3816521 to your computer and use it in GitHub Desktop.
agregar digito 9
import sqlite3
import pdb
conn = sqlite3.connect('AddressBook.sqlitedb')
c = conn.cursor()
sql = "select ABMultiValue.value, ABPerson.ROWID from ABPerson,ABMultiValue where ABMultiValue.record_id=ABPerson.ROWID"
ins = "update ABMultiValue set value='%s' where record_id=%s"
l = [9,12]
prefix = ['08','09','06','05','03']
c.execute(sql)
res = c.fetchall()
for item in res:
if item[0] and len(item[0]) in l:
es = ins % (new,item[1])
if item[0].startswith('+593'):
new = '+5939'+item[0][4:]
c.execute(es)
conn.commit()
elif item[0][:2] in prefix:
new = '09'+item[0][1:]
c.execute(es)
conn.commit()
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment