Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
StorageLeaf
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ProjectLeaf
StorageLeaf
Commits
f6d7a014
Commit
f6d7a014
authored
4 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
cleanup old database access
parent
f6578555
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/logic/database/DeviceAccess.py
+0
-33
0 additions, 33 deletions
src/logic/database/DeviceAccess.py
src/logic/database/SensorAccess.py
+0
-47
0 additions, 47 deletions
src/logic/database/SensorAccess.py
with
0 additions
and
80 deletions
src/logic/database/DeviceAccess.py
deleted
100644 → 0
+
0
−
33
View file @
f6578555
import
logging
from
typing
import
Dict
,
List
from
logic
import
Constants
from
logic.database.DatabaseAccess
import
DatabaseAccess
,
FetchType
LOGGER
=
logging
.
getLogger
(
Constants
.
APP_NAME
)
class
DeviceAccess
(
DatabaseAccess
):
TABLE_NAME
=
'
device
'
def
create_table
(
self
):
self
.
_query
(
f
'''
CREATE TABLE IF NOT EXISTS
{
self
.
TABLE_NAME
}
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL)
'''
,
fetch_type
=
FetchType
.
CREATE
)
def
get_all_devices
(
self
)
->
List
[
Dict
[
str
,
str
]]:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
ORDER BY name
'
,
fetch_type
=
FetchType
.
ALL
)
def
get_device
(
self
,
deviceID
:
int
)
->
Dict
[
str
,
str
]
or
None
:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
WHERE id = ?
'
,
deviceID
,
fetch_type
=
FetchType
.
ONE
)
def
get_device_by_name
(
self
,
deviceName
:
str
)
->
Dict
[
str
,
str
]
or
None
:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
WHERE name = ?
'
,
deviceName
,
fetch_type
=
FetchType
.
ONE
)
def
add_device
(
self
,
deviceName
:
str
):
LOGGER
.
debug
(
f
'
Inserting new device
"
{
deviceName
}
"'
)
self
.
_query
(
f
'
INSERT INTO
{
self
.
TABLE_NAME
}
(name) VALUES(?)
'
,
deviceName
,
fetch_type
=
FetchType
.
NONE
)
def
delete_device
(
self
,
deviceID
:
int
):
LOGGER
.
debug
(
f
'
Deleting device
"
{
deviceID
}
"'
)
self
.
_query
(
f
'
DELETE FROM
{
self
.
TABLE_NAME
}
WHERE id = ?
'
,
deviceID
,
fetch_type
=
FetchType
.
NONE
)
This diff is collapsed.
Click to expand it.
src/logic/database/SensorAccess.py
deleted
100644 → 0
+
0
−
47
View file @
f6578555
import
logging
from
typing
import
Dict
,
List
from
logic
import
Constants
from
logic.database.DatabaseAccess
import
DatabaseAccess
,
FetchType
LOGGER
=
logging
.
getLogger
(
Constants
.
APP_NAME
)
class
SensorAccess
(
DatabaseAccess
):
TABLE_NAME
=
'
sensor
'
def
create_table
(
self
):
self
.
_query
(
f
'''
CREATE TABLE IF NOT EXISTS
{
self
.
TABLE_NAME
}
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
device_id INTEGER,
name TEXT NOT NULL,
type TEXT NOT NULL)
'''
,
fetch_type
=
FetchType
.
CREATE
)
def
get_all_sensors
(
self
)
->
List
[
Dict
[
str
,
str
]]:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
ORDER BY device_id, id
'
,
fetch_type
=
FetchType
.
ALL
)
def
get_all_sensors_for_device
(
self
,
deviceID
:
int
)
->
List
[
Dict
[
str
,
str
]]:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
WHERE device_id = ? ORDER BY id
'
,
deviceID
,
fetch_type
=
FetchType
.
ALL
)
def
get_sensor
(
self
,
sensorID
:
int
)
->
Dict
[
str
,
str
]
or
None
:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
WHERE id = ?
'
,
sensorID
,
fetch_type
=
FetchType
.
ONE
)
def
get_sensor_by_name_and_device_id
(
self
,
deviceID
:
int
,
sensorName
:
str
)
->
Dict
[
str
,
str
]
or
None
:
return
self
.
_query
(
f
'
SELECT * FROM
{
self
.
TABLE_NAME
}
WHERE device_id = ? AND name = ?
'
,
deviceID
,
sensorName
,
fetch_type
=
FetchType
.
ONE
)
def
add_sensor
(
self
,
deviceID
:
int
,
name
:
str
,
sensorType
:
str
):
LOGGER
.
debug
(
f
'
Inserting new
"
{
sensorType
}
"
sensor
"
{
name
}
"
for device
"
{
deviceID
}
"'
)
self
.
_query
(
f
'
INSERT INTO
{
self
.
TABLE_NAME
}
(name, device_id, type)
'
f
'
VALUES(?, ?, ?)
'
,
name
,
deviceID
,
sensorType
,
fetch_type
=
FetchType
.
NONE
)
def
delete_sensor
(
self
,
sensorID
:
int
):
LOGGER
.
debug
(
f
'
Deleting sensor
"
{
sensorID
}
"'
)
self
.
_query
(
f
'
DELETE FROM
{
self
.
TABLE_NAME
}
WHERE id = ?
'
,
sensorID
,
fetch_type
=
FetchType
.
NONE
)
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