コード例 #1
0
def create_table():
    """Create a table"""
    queries = ["CREATE TABLE %s (%s VARCHAR(32) PRIMARY KEY, %s REAL)" % (table_name, filename_column, time_column),
               get_index_query(table_name, filename_column),
               get_index_query(table_name, time_column)]
    for query in queries:
        execute_query(settings.database, query)
コード例 #2
0
ファイル: detections_dao.py プロジェクト: cmeijer/camera
def create_table():
    """Create a table"""
    foreign_key_query = 'FOREIGN KEY(%s) REFERENCES %s(%s)' % (
        image_column, images_table_name, images_filename_column)
    query = "CREATE TABLE %s (%s VARCHAR(32) PRIMARY KEY, %s VARCHAR(32), %s VARCHAR(64), %s VARCHAR(32), %s)" % (
        table_name, id_column, image_column, object_type_column,
        bounding_box_column, foreign_key_query)
    execute_query(settings.database, query)
コード例 #3
0
def create_table():
    """Create a table"""
    queries = [
        "CREATE TABLE %s (%s VARCHAR(32), %s VARCHAR(32), %s REAL, %s VARCHAR(128))"
        % (table_name, ip_column, mac_column, time_column, description_column),
        get_index_query(table_name, time_column),
        get_index_query(table_name, mac_column)
    ]
    for query in queries:
        execute_query(settings.database, query)
コード例 #4
0
ファイル: detections_dao.py プロジェクト: cmeijer/camera
def get_last_detections(max_results=5):
    query = 'SELECT * FROM {} INNER JOIN {} ON {}.image={}.filename ORDER BY {} DESC LIMIT {}' \
        .format(table_name, images_table_name, table_name, images_table_name, images_time_column, max_results)
    results = execute_query(settings.database, query)
    return results
コード例 #5
0
ファイル: detections_dao.py プロジェクト: cmeijer/camera
def get_all_detections(max_results=5):
    query = 'SELECT * FROM {} DESC LIMIT {}'.format(table_name, max_results)
    results = execute_query(settings.database, query)
    return results
コード例 #6
0
ファイル: detections_dao.py プロジェクト: cmeijer/camera
def save_or_update(filename, object_type, bounding_box=None):
    new_id = uuid.uuid4()
    query = 'INSERT INTO {} VALUES ("{}", "{}", "{}", "{}")' \
        .format(table_name, new_id, filename, object_type, bounding_box)
    execute_query(settings.database, query)
    return new_id
コード例 #7
0
def get_all_connections(max_results=5):
    query = 'SELECT * FROM {} ORDER BY {} DESC LIMIT {}'.format(
        table_name, time_column, max_results)
    results = execute_query(settings.database, query)
    return results
コード例 #8
0
def get_time_by_mac(mac):
    query = 'SELECT {} FROM {} WHERE {} = "{}" ORDER BY {} DESC'.format(
        time_column, table_name, mac_column, mac, time_column)
    results = execute_query(settings.database, query)
    return parse(results[0][0])
コード例 #9
0
def save_or_update(ip, mac, time, description):
    query = 'INSERT INTO {} VALUES ("{}", "{}", {}, "{}")'.format(
        table_name, ip, mac, time, description)
    execute_query(settings.database, query)
コード例 #10
0
def save_or_update(filename, seconds):
    query = 'INSERT INTO {} VALUES ("{}", {})'.format(table_name, filename, seconds)
    execute_query(settings.database, query)