Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Module 4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Service
Module 4
Commits
d15e6e86
Commit
d15e6e86
authored
10 months ago
by
IIKhalimov
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
c41a2219
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Add new directory
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DataBase/db-back.py
+94
-0
94 additions, 0 deletions
DataBase/db-back.py
with
94 additions
and
0 deletions
DataBase/db-back.py
0 → 100644
+
94
−
0
View file @
d15e6e86
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment