dev: 增加删除功能
This commit is contained in:
@@ -363,7 +363,7 @@ class Sqlite3Worker(object):
|
||||
return ", ".join(columns_str_ls)
|
||||
|
||||
def insert_into(self, table_name: str, columns: list[Column | str],
|
||||
values: list[list[str | int | float]],
|
||||
values: list[list[str | int | float | BlobType]],
|
||||
*, execute: bool = True, commit: bool = True) -> str:
|
||||
col_count = len(columns)
|
||||
columns_str = self._columns_to_string(columns)
|
||||
|
||||
@@ -42,8 +42,8 @@ def get_app_dir(org_name: str, app_name: str) -> Path:
|
||||
|
||||
|
||||
def get_config_path(org_name: str, app_name: str) -> Path:
|
||||
data_dir = get_app_dir(org_name, app_name)
|
||||
return Path(data_dir, "config.json")
|
||||
app_dir = get_app_dir(org_name, app_name)
|
||||
return Path(app_dir, "config.json")
|
||||
|
||||
|
||||
def read_config(org_name: str, app_name: str) -> dict:
|
||||
@@ -71,3 +71,8 @@ def get_default_db_path(config: dict, org_name: str, app_name: str) -> str:
|
||||
app_dir = get_app_dir(org_name, app_name)
|
||||
return str(app_dir / f"default.db")
|
||||
return config["last_db_path"]
|
||||
|
||||
|
||||
def get_secrets_path(org_name: str, app_name: str) -> str:
|
||||
app_dir = get_app_dir(org_name, app_name)
|
||||
return str(app_dir / "secrets.db")
|
||||
|
||||
@@ -13,6 +13,7 @@ columns_d = {
|
||||
"filepath": Column("filepath", DataType.BLOB, nullable=False),
|
||||
"path": Column("path", DataType.BLOB),
|
||||
"status": Column("status", DataType.TEXT), # 只有三种状态:keep, transfer, delete
|
||||
"deleted": Column("deleted", DataType.INTEGER, has_default=True, default=0), # 布尔,只有 1 或者 0
|
||||
}
|
||||
|
||||
all_columns = [
|
||||
@@ -27,10 +28,11 @@ all_columns = [
|
||||
columns_d["filepath"],
|
||||
columns_d["path"],
|
||||
columns_d["status"],
|
||||
columns_d["deleted"],
|
||||
]
|
||||
|
||||
# 插入数据时使用的列
|
||||
insert_columns = all_columns[1:-1]
|
||||
insert_columns = all_columns[1:-2]
|
||||
|
||||
# 查询数据时使用的列
|
||||
query_columns = [
|
||||
@@ -47,6 +49,8 @@ sim_columns = [
|
||||
columns_d["filepath"],
|
||||
]
|
||||
|
||||
uuid_col = columns_d["uuid"]
|
||||
filepath_col = columns_d["filepath"]
|
||||
entry_id_col = columns_d["entry_id"]
|
||||
status_col = columns_d["status"]
|
||||
deleted_col = columns_d["deleted"]
|
||||
|
||||
19
lib/sec_db_columns_def.py
Normal file
19
lib/sec_db_columns_def.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# coding: utf8
|
||||
from .Sqlite3Helper import Column, DataType
|
||||
|
||||
sec_columns_d = {
|
||||
"secret_id": Column("secret_id", DataType.INTEGER, primary_key=True, unique=True),
|
||||
"filepath": Column("filepath", DataType.BLOB),
|
||||
"password": Column("password", DataType.BLOB),
|
||||
}
|
||||
|
||||
sec_all_columns = [
|
||||
sec_columns_d["secret_id"],
|
||||
sec_columns_d["filepath"],
|
||||
sec_columns_d["password"],
|
||||
]
|
||||
|
||||
insert_sec_columns = sec_all_columns[1:]
|
||||
|
||||
sec_filepath_col = sec_columns_d["filepath"]
|
||||
sec_password_col = sec_columns_d["password"]
|
||||
Reference in New Issue
Block a user