Skip to content
Snippets Groups Projects
Commit 1922e1c5 authored by L0ckR's avatar L0ckR
Browse files

Merge branch 'develop' of https://gitlab.mai.ru/serviece/module-4 into develop

parents 1f9099fd d15e6e86
No related branches found
No related tags found
1 merge request!1Add new directory
import sqlite3
import csv
database = sqlite3.connect('telemetry.db')
c = database.cursor()
def create_t():
c.execute("""CREATE TABLE telemetry (
id INTEGER PRIMARY KEY,
frame INTEGER,
video_start_time DATETIME,
video_stop_time DATETIME,
timestamp TIMESTAMP,
iso REAL,
shutter REAL,
fnum REAL,
ev REAL,
focal_len REAL,
dzoom REAL,
latitude REAL,
longitude REAL,
rel_alt REAL,
abs_alt REAL,
drone_speedx REAL,
drone_speedy REAL,
drone_speedz REAL,
drone_yaw REAL,
drone_pitch REAL,
drone_roll REAL,
gb_yaw REAL,
gb_pitch REAL,
gb_roll REAL,
ae_meter_md REAL,
dzoom_ratio REAL,
delta REAL,
color_md STRING,
ct REAL
)""")
def insert_data(data):
query = '''INSERT INTO telemetry (frame, video_start_time, video_stop_time, timestamp, iso, shutter, fnum, ev,
focal_len, dzoom, latitude, longitude, rel_alt, abs_alt, drone_speedx,
drone_speedy, drone_speedz, drone_yaw, drone_pitch, drone_roll, gb_yaw,
gb_pitch, gb_roll, ae_meter_md, dzoom_ratio, delta, color_md, ct)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'''
c.execute(query, data)
database.commit()
def read_data():
query = """SELECT * FROM telemetry LIMIT 3;"""
c.execute(query)
rows = c.fetchall()
for row in rows:
print(row)
def read_csv_and_insert_to_db(csv_file):
with open(csv_file, newline='') as file:
reader = csv.DictReader(file)
for row in reader:
data = (
int(row['frame']),
row['video_start_time'],
row['video_stop_time'],
int(row['timestamp']),
float(row['iso']),
row['shutter'],
float(row['fnum']),
float(row['ev']),
float(row['focal_len']),
float(row['dzoom']),
float(row['latitude']),
float(row['longitude']),
float(row['rel_alt']),
float(row['abs_alt']),
float(row['drone_speedx']),
float(row['drone_speedy']),
float(row['drone_speedz']),
float(row['drone_yaw']),
float(row['drone_pitch']),
float(row['drone_roll']),
float(row['gb_yaw']),
float(row['gb_pitch']),
float(row['gb_roll']),
float(row['ae_meter_md']),
float(row['dzoom_ratio']),
float(row['delta']),
row['color_md'],
float(row['ct'])
)
insert_data(data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment