style: apply flake8 and black formatting

To check for errors:
$ pre-commit run --all-files

To install as pre-commit hook:
$ pre-commit install
This commit is contained in:
Pim van den Berg 2021-05-30 14:09:27 +02:00
parent 8c7d0ed947
commit 751182b70d
8 changed files with 171 additions and 89 deletions

38
db.py
View file

@ -2,7 +2,7 @@ import sqlite3
from sqlite3 import Error
class sqlite():
class sqlite:
def __init__(self, db_file):
self.conn = self.connect(db_file)
@ -34,15 +34,17 @@ class sqlite():
print("Error:", e)
def create_table(self, t):
if t.startswith('datalabel'):
if t.startswith("datalabel"):
query = """CREATE TABLE {} (
id real,
name text,
title text,
tooltip text,
unit text
);""".format(t)
elif t.startswith('parameterlijst'):
);""".format(
t
)
elif t.startswith("parameterlijst"):
query = """
CREATE TABLE {} (
id real,
@ -54,32 +56,42 @@ class sqlite():
title text,
description text,
unit text
);""".format(t)
elif t.startswith('versiebeheer'):
);""".format(
t
)
elif t.startswith("versiebeheer"):
query = """
CREATE TABLE {} (
version integer primary key,
datalabel integer,
parameterlist integer
);""".format(t)
);""".format(
t
)
self.execute(query)
self.conn.commit()
def insert(self, t, data):
if t.startswith('datalabel'):
if t.startswith("datalabel"):
query = """
INSERT INTO {} (id, name, title, tooltip, unit)
VALUES (?, ?, ?, ?, ?);
""".format(t)
elif t.startswith('parameterlijst'):
""".format(
t
)
elif t.startswith("parameterlijst"):
query = """
INSERT INTO {} (id, name, name_factory, min, max, def, title, description, unit)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
""".format(t)
elif t.startswith('versiebeheer'):
""".format(
t
)
elif t.startswith("versiebeheer"):
query = """
INSERT INTO {} (version, datalabel, parameterlist)
VALUES (?, ?, ?);
""".format(t)
""".format(
t
)
self.executemany(query, data)
self.conn.commit()