# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.7.9 64-bit (''pose37'': conda)'
#     name: python3
# ---

import os
print(os.getcwd())
os.chdir('d:/Users/mokky/Documents/GitHub/NUS-ISS/IS02_PT_Capstone_Human_Re-ID')
print(os.getcwd())


import sqlite3
from src.database.database import DbQuery
import pandas as pd
import matplotlib.pyplot as plt
import cv2
import numpy as np


db_path = 'reid/Reid_20210816.db'
query = "SELECT name FROM sqlite_master WHERE type='table'"
conn = sqlite3.connect(db_path, detect_types=sqlite3.PARSE_DECLTYPES |
                          sqlite3.PARSE_COLNAMES)
cursor = conn.cursor()
cursor.execute(query)
column_names = [desc[0] for desc in cursor.description]
qry_results = pd.DataFrame(cursor.fetchall(), columns=column_names)
print(qry_results)
print(qry_results.name.tolist())


table_name = 'vectorkb_table'
query = f'SELECT * FROM {table_name}'
cursor.execute(query)
column_names = [desc[0] for desc in cursor.description]
qry_results = pd.DataFrame(cursor.fetchall(), columns=column_names)
display(qry_results.info())
display(qry_results.head())


sorted(qry_results.cam_id.unique().tolist())
for cam_id in sorted(qry_results.cam_id.unique().tolist()):
    for idx, row in qry_results[qry_results.cam_id == cam_id].iterrows():
        print(row.cam_id)


table_name = 'vectorkb_table'
query = f"SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='{table_name}'"
cursor.execute(query)
column_names = [desc[0] for desc in cursor.description]
qry_results = pd.DataFrame(cursor.fetchall(), columns=column_names)
display(qry_results.info())
display(qry_results.head())


table_name = 'sqlite_sequence'
query = f'SELECT * FROM {table_name}'
cursor.execute(query)
column_names = [desc[0] for desc in cursor.description]
qry_results = pd.DataFrame(cursor.fetchall(), columns=column_names)
display(qry_results.info())
display(qry_results.head())


table_name = 'VectorKB_Table'
query = f'SELECT DISTINCT(cam_id) FROM {table_name}'
cursor.execute(query)
column_names = [desc[0] for desc in cursor.description]
qry_results = pd.DataFrame(cursor.fetchall(), columns=column_names)
display(qry_results.info())
display(qry_results.head())


table_name = 'VectorKB_Table'
query = f'SELECT timestamp FROM {table_name}'
cursor.execute(query)
column_names = [desc[0] for desc in cursor.description]
qry_results = pd.DataFrame(cursor.fetchall(), columns=column_names)
display(qry_results.info())
display(qry_results.min(), qry_results.max())


StarcoderdataJupyterScriptsDedupFiltered