import csv, sqlite3
con = sqlite3.connect("database_modfire.db")
cur = con.cursor()
fin = open("i.csv", "rt")
for line in fin:
cur.execute("SELECT internal FROM ug_ids WHERE external = "+line+";")
ugid = cur.fetchall()
print("% s" % ugid[0] + ",")
con.commit()
con.close()
fin.close()