bouquin 0.1.7__tar.gz → 0.1.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bouquin
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Bouquin is a simple, opinionated notebook application written in Python, PyQt and SQLCipher.
5
5
  Home-page: https://git.mig5.net/mig5/bouquin
6
6
  License: GPL-3.0-or-later
@@ -56,6 +56,10 @@ There is deliberately no network connectivity or syncing intended.
56
56
 
57
57
  Make sure you have `libxcb-cursor0` installed (it may be called something else on non-Debian distributions).
58
58
 
59
+ ### From PyPi/pip
60
+
61
+ * `pip install bouquin`
62
+
59
63
  ### From source
60
64
 
61
65
  * Clone this repo or download the tarball from the releases page
@@ -67,15 +71,10 @@ Make sure you have `libxcb-cursor0` installed (it may be called something else o
67
71
 
68
72
  * Download the whl and run it
69
73
 
70
- ### From PyPi/pip
71
-
72
- * `pip install bouquin`
73
-
74
-
75
74
  ## How to run the tests
76
75
 
77
76
  * Clone the repo
78
77
  * Ensure you have poetry installed
79
78
  * Run `poetry install --with test`
80
- * Run `poetry run pytest -vvv`
79
+ * Run `poetry run pytest -vvvv --cov=bouquin`
81
80
 
@@ -36,6 +36,10 @@ There is deliberately no network connectivity or syncing intended.
36
36
 
37
37
  Make sure you have `libxcb-cursor0` installed (it may be called something else on non-Debian distributions).
38
38
 
39
+ ### From PyPi/pip
40
+
41
+ * `pip install bouquin`
42
+
39
43
  ### From source
40
44
 
41
45
  * Clone this repo or download the tarball from the releases page
@@ -47,14 +51,9 @@ Make sure you have `libxcb-cursor0` installed (it may be called something else o
47
51
 
48
52
  * Download the whl and run it
49
53
 
50
- ### From PyPi/pip
51
-
52
- * `pip install bouquin`
53
-
54
-
55
54
  ## How to run the tests
56
55
 
57
56
  * Clone the repo
58
57
  * Ensure you have poetry installed
59
58
  * Run `poetry install --with test`
60
- * Run `poetry run pytest -vvv`
59
+ * Run `poetry run pytest -vvvv --cov=bouquin`
@@ -133,7 +133,7 @@ class DBManager:
133
133
  raise RuntimeError("Database is not connected")
134
134
  cur = self.conn.cursor()
135
135
  # Change the encryption key of the currently open database
136
- cur.execute(f"PRAGMA rekey = '{new_key}';")
136
+ cur.execute(f"PRAGMA rekey = '{new_key}';").fetchone()
137
137
  self.conn.commit()
138
138
 
139
139
  # Close and reopen with the new key to verify and restore PRAGMAs
@@ -409,7 +409,7 @@ class DBManager:
409
409
  f.write(separator)
410
410
 
411
411
  def export_html(
412
- self, entries: Sequence[Entry], file_path: str, title: str = "Entries export"
412
+ self, entries: Sequence[Entry], file_path: str, title: str = "Bouquin export"
413
413
  ) -> None:
414
414
  parts = [
415
415
  "<!doctype html>",
@@ -430,6 +430,25 @@ class DBManager:
430
430
  with open(file_path, "w", encoding="utf-8") as f:
431
431
  f.write("\n".join(parts))
432
432
 
433
+ def export_sql(self, file_path: str) -> None:
434
+ """
435
+ Exports the encrypted database as plaintext SQL.
436
+ """
437
+ cur = self.conn.cursor()
438
+ cur.execute(f"ATTACH DATABASE '{file_path}' AS plaintext KEY '';")
439
+ cur.execute("SELECT sqlcipher_export('plaintext')")
440
+ cur.execute("DETACH DATABASE plaintext")
441
+
442
+ def export_sqlcipher(self, file_path: str) -> None:
443
+ """
444
+ Exports the encrypted database as an encrypted database with the same key.
445
+ Intended for Bouquin-compatible backups.
446
+ """
447
+ cur = self.conn.cursor()
448
+ cur.execute(f"ATTACH DATABASE '{file_path}' AS backup KEY '{self.cfg.key}'")
449
+ cur.execute("SELECT sqlcipher_export('backup')")
450
+ cur.execute("DETACH DATABASE backup")
451
+
433
452
  def export_by_extension(self, file_path: str) -> None:
434
453
  entries = self.get_all_entries()
435
454
  ext = os.path.splitext(file_path)[1].lower()
@@ -445,6 +464,16 @@ class DBManager:
445
464
  else:
446
465
  raise ValueError(f"Unsupported extension: {ext}")
447
466
 
467
+ def compact(self) -> None:
468
+ """
469
+ Runs VACUUM on the db.
470
+ """
471
+ try:
472
+ cur = self.conn.cursor()
473
+ cur.execute("VACUUM")
474
+ except Exception as e:
475
+ print(f"Error: {e}")
476
+
448
477
  def close(self) -> None:
449
478
  if self.conn is not None:
450
479
  self.conn.close()