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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ProjectLeaf
StorageLeaf
Commits
cc6d5831
Commit
cc6d5831
authored
4 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
cleanup old classes
parent
8c5b0b60
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/DatabaseAccess.py
+0
-57
0 additions, 57 deletions
src/logic/database/DatabaseAccess.py
src/logic/database/__init__.py
+0
-0
0 additions, 0 deletions
src/logic/database/__init__.py
with
0 additions
and
57 deletions
src/logic/database/DatabaseAccess.py
deleted
100644 → 0
+
0
−
57
View file @
8c5b0b60
import
abc
import
logging
import
sqlite3
from
abc
import
ABC
from
enum
import
Enum
from
logic
import
Constants
from
logic.BackupService
import
BackupService
LOGGER
=
logging
.
getLogger
(
Constants
.
APP_NAME
)
class
FetchType
(
Enum
):
NONE
=
1
ONE
=
2
ALL
=
3
CREATE
=
4
class
DatabaseAccess
(
ABC
):
DATE_FORMAT
=
'
%Y-%m-%d %H:%M:%S
'
@staticmethod
def
namedtuple_factory
(
cursor
,
row
):
"""
Returns sqlite rows as dicts.
"""
d
=
{}
for
idx
,
col
in
enumerate
(
cursor
.
description
):
d
[
col
[
0
]]
=
row
[
idx
]
return
d
def
__init__
(
self
,
databasePath
,
backupService
:
BackupService
):
self
.
_databasePath
=
databasePath
self
.
_backupService
=
backupService
@abc.abstractmethod
def
create_table
(
self
):
pass
def
_query
(
self
,
query
,
*
args
,
fetch_type
=
FetchType
.
ALL
):
connection
=
sqlite3
.
connect
(
self
.
_databasePath
)
connection
.
row_factory
=
DatabaseAccess
.
namedtuple_factory
with
connection
:
cursor
=
connection
.
cursor
()
try
:
cursor
.
execute
(
query
,
args
)
if
fetch_type
==
FetchType
.
ONE
:
return
cursor
.
fetchone
()
if
fetch_type
==
FetchType
.
ALL
:
return
cursor
.
fetchall
()
if
fetch_type
==
FetchType
.
NONE
:
self
.
_backupService
.
perform_modification
()
finally
:
cursor
.
close
()
This diff is collapsed.
Click to expand it.
src/logic/database/__init__.py
deleted
100644 → 0
+
0
−
0
View file @
8c5b0b60
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