try: conn = MySQLdb.connect( host=config["db_host"], user=config["db_user"], passwd=config["db_pass"], db=config["db_name"], charset="utf8", ) except: print ("Error: Can't connect to database") exit(-1) else: conn = sqlite3.connect(config["db_name"] + ".sqlite") if options.reset: lucicat_utils.reset_database(conn, config) c = conn.cursor() def get_text(node): rc = "" for nod in node.childNodes: if nod.nodeType == nod.TEXT_NODE: rc = rc + nod.nodeValue elif nod.nodeType == nod.ELEMENT_NODE: rc = rc + get_text(nod) return rc.strip() for atom_file in args:
def do_reset_database(): lucicat_utils.reset_database(conn, config)
if config['db_type'] == "mysql": import MySQLdb try: conn = MySQLdb.connect(host=config['db_host'], user=config['db_user'], passwd=config['db_pass'], db=config['db_name'], charset="utf8") except: print("Error: Can't connect to database") exit(-1) else: conn = sqlite3.connect(config['db_name'] + ".sqlite") if options.reset: lucicat_utils.reset_database(conn, config) c = conn.cursor() def get_text(node): rc = "" for nod in node.childNodes: if nod.nodeType == nod.TEXT_NODE: rc = rc + nod.nodeValue elif nod.nodeType == nod.ELEMENT_NODE: rc = rc + get_text(nod) return rc.strip() for atom_file in args: