Esempio n. 1
0
def insert(data):
    try:
        control.makeFile(control.dataPath)
        cacheFile = os.path.join(control.dataPath, 'regex.db')
        dbcon = database.connect(cacheFile)
        dbcur = dbcon.cursor()
        dbcur.execute("CREATE TABLE IF NOT EXISTS regex ("
                      "regex TEXT, "
                      "response TEXT, "
                      "UNIQUE(regex)"
                      ");")
        for i in data:
            try:
                dbcur.execute("INSERT INTO regex Values (?, ?)",
                              (i['regex'], i['response']))
            except:
                pass
        dbcon.commit()
    except:
        return
Esempio n. 2
0
def _get_connection_providers():
    control.makeFile(control.dataPath)
    conn = db.connect(control.providercacheFile)
    conn.row_factory = _dict_factory
    return conn
Esempio n. 3
0
def _get_connection_search():
    control.makeFile(control.dataPath)
    conn = db.connect(control.searchFile)
    conn.row_factory = _dict_factory
    return conn
Esempio n. 4
0
def _get_connection_meta():
    control.makeFile(control.dataPath)
    conn = db.connect(control.metacacheFile)
    conn.row_factory = _dict_factory
    return conn