Пример #1
0
def query_one(_id):
    db = SqlLite3Tools()
    row = db.query_one("monitor", _id)
    item = {
        'id': row[0],
        'title': row[1],
        'receiver': row[2],
        'cron_str': row[3],
        'sql_str': row[4],
        'source': row[5]
    }
    return item
def query_one(_id):
    db = SqlLite3Tools()
    row = db.query_one("source_config", _id)
    item = {
        'id': row[0],
        'name': row[1],
        'host': row[2],
        'port': row[3],
        'username': row[4],
        'password': row[5],
        'database': row[6]
    }
    return item
Пример #3
0
def query_all():
    db = SqlLite3Tools(create_sql=create_sql)
    rows = db.query_all("monitor")
    result = list()
    if rows:
        for row in rows:
            item = {
                'id': row[0],
                'title': row[1],
                'receiver': row[2],
                'cron_str': row[3],
                'sql_str': row[4],
                'source': row[5]
            }
            result.append(item)
    return result
def query_all():
    db = SqlLite3Tools(create_sql=create_sql)
    rows = db.query_all("source_config")
    result = list()
    if rows:
        for row in rows:
            item = {
                'id': row[0],
                'name': row[1],
                'host': row[2],
                'port': row[3],
                'username': row[4],
                'password': row[5],
                'database': row[6]
            }
            result.append(item)
    return result
def query_by_name(name):
    db = SqlLite3Tools()
    row = db.query_by_sql("select * from source_config where name = '%s'" %
                          name)
    if len(row) > 0:
        row = row[0]
        item = {
            'id': row[0],
            'name': row[1],
            'host': row[2],
            'port': row[3],
            'username': row[4],
            'password': row[5],
            'database': row[6]
        }
        return item
    else:
        return None
def execute_delete(_id):
    db = SqlLite3Tools()
    db.execute_delete('source_config', _id)
def execute_save(insert_data):
    db = SqlLite3Tools(create_sql=create_sql)
    sql = 'insert into source_config (name,host,port,username,password,database) values (?,?,?,?,?,?)'\
        if len(insert_data) == 6 \
        else 'update source_config set name= ? ,host=?,port=?,username=?,password=?,database=? where id = ?'
    db.execute_save(sql, insert_data)
Пример #8
0
def execute_delete(_id):
    db = SqlLite3Tools()
    db.execute_delete('monitor', _id)
Пример #9
0
def execute_save(insert_data):
    db = SqlLite3Tools(create_sql=create_sql)
    sql = 'insert into monitor (title,receiver,cron_str,sql_str,source) values (?,?,?,?,?)'\
        if len(insert_data) == 5 \
        else 'update monitor set title= ? ,receiver=?,cron_str=?,sql_str=?,source=? where id = ?'
    db.execute_save(sql, insert_data)