passwd=DATABASE_PASSWORD, db=DATABASE_NAME) g = DBGeneric(db.con) report, photcs, dbEntries = get_report(g, csvFile) print report try: ans = raw_input( "Do you want to merge PHOTC data from the file into the database? " ) if ans in ('y', 'Y', 'yes', 'YES'): start = time.time() g.begin() g.setTableName('youpi_image') try: update = 0 for e in dbEntries: g.update(photc=photcs[e[0]], wheres={'name': e[0]}) update += 1 g.con.commit() except: g.con.rollback() print "Error:", e sys.exit(1) print "Done. %d PHOTC fields merged." % update print "Time elapsed: %.02f sec" % (time.time() - start) else:
print "Usage: %s <csv_file>" % sys.argv[0] sys.exit(1) db = DB(host=DATABASE_HOST, user=DATABASE_USER, passwd=DATABASE_PASSWORD, db=DATABASE_NAME) g = DBGeneric(db.con) report, photcs, dbEntries = get_report(g, csvFile) print report try: ans = raw_input("Do you want to merge PHOTC data from the file into the database? ") if ans in ("y", "Y", "yes", "YES"): start = time.time() g.begin() g.setTableName("youpi_image") try: update = 0 for e in dbEntries: g.update(photc=photcs[e[0]], wheres={"name": e[0]}) update += 1 g.con.commit() except: g.con.rollback() print "Error:", e sys.exit(1) print "Done. %d PHOTC fields merged." % update print "Time elapsed: %.02f sec" % (time.time() - start) else: