datasette-scan 0.1__py3-none-any.whl → 0.1.1__py3-none-any.whl
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.
- datasette_scan/__init__.py +9 -12
- {datasette_scan-0.1.dist-info → datasette_scan-0.1.1.dist-info}/METADATA +1 -1
- datasette_scan-0.1.1.dist-info/RECORD +7 -0
- datasette_scan-0.1.dist-info/RECORD +0 -7
- {datasette_scan-0.1.dist-info → datasette_scan-0.1.1.dist-info}/WHEEL +0 -0
- {datasette_scan-0.1.dist-info → datasette_scan-0.1.1.dist-info}/entry_points.txt +0 -0
- {datasette_scan-0.1.dist-info → datasette_scan-0.1.1.dist-info}/licenses/LICENSE +0 -0
- {datasette_scan-0.1.dist-info → datasette_scan-0.1.1.dist-info}/top_level.txt +0 -0
datasette_scan/__init__.py
CHANGED
|
@@ -12,16 +12,19 @@ import time
|
|
|
12
12
|
import sqlite_scanner
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def validate_databases(paths):
|
|
15
|
+
def validate_databases(paths, nolock=False):
|
|
16
16
|
"""Check each path is a readable SQLite database.
|
|
17
17
|
|
|
18
18
|
Returns (valid, skipped) where skipped is a list of (path, reason) tuples.
|
|
19
19
|
"""
|
|
20
20
|
valid = []
|
|
21
21
|
skipped = []
|
|
22
|
+
qs = "?mode=ro"
|
|
23
|
+
if nolock:
|
|
24
|
+
qs += "&nolock=1"
|
|
22
25
|
for path in paths:
|
|
23
26
|
try:
|
|
24
|
-
conn = sqlite3.connect(f"file:{path}
|
|
27
|
+
conn = sqlite3.connect(f"file:{path}{qs}", uri=True)
|
|
25
28
|
try:
|
|
26
29
|
conn.execute("SELECT * FROM sqlite_master")
|
|
27
30
|
valid.append(path)
|
|
@@ -39,18 +42,14 @@ def scan_directories(directories):
|
|
|
39
42
|
"""
|
|
40
43
|
binary = sqlite_scanner.get_binary_path()
|
|
41
44
|
if not os.path.exists(binary):
|
|
42
|
-
raise click.ClickException(
|
|
43
|
-
f"sqlite-scanner binary not found at {binary}"
|
|
44
|
-
)
|
|
45
|
+
raise click.ClickException(f"sqlite-scanner binary not found at {binary}")
|
|
45
46
|
result = subprocess.run(
|
|
46
47
|
[binary, "--jsonl"] + list(directories),
|
|
47
48
|
capture_output=True,
|
|
48
49
|
text=True,
|
|
49
50
|
)
|
|
50
51
|
if result.returncode != 0:
|
|
51
|
-
raise click.ClickException(
|
|
52
|
-
f"sqlite-scanner failed: {result.stderr.strip()}"
|
|
53
|
-
)
|
|
52
|
+
raise click.ClickException(f"sqlite-scanner failed: {result.stderr.strip()}")
|
|
54
53
|
paths = []
|
|
55
54
|
for line in result.stdout.strip().splitlines():
|
|
56
55
|
if line:
|
|
@@ -117,11 +116,9 @@ def register_commands(cli):
|
|
|
117
116
|
|
|
118
117
|
# Validate scanned files, skip corrupted ones
|
|
119
118
|
if scanned_files:
|
|
120
|
-
valid, skipped = validate_databases(scanned_files)
|
|
119
|
+
valid, skipped = validate_databases(scanned_files, nolock=True)
|
|
121
120
|
for path, reason in skipped:
|
|
122
|
-
click.echo(
|
|
123
|
-
f"Skipping {path}: {reason}", err=True
|
|
124
|
-
)
|
|
121
|
+
click.echo(f"Skipping {path}: {reason}", err=True)
|
|
125
122
|
db_files.extend(valid)
|
|
126
123
|
|
|
127
124
|
# Always use nolock for safety with discovered files
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
datasette_scan/__init__.py,sha256=H5dsmxe--yjPNH9uOjkINHNlrhejASX45cPxTBedB50,5998
|
|
2
|
+
datasette_scan-0.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
3
|
+
datasette_scan-0.1.1.dist-info/METADATA,sha256=Eu7YRf0ZcHSNpmSnnt5cnf8R-2ZMWacz7LHINmrdXXc,4210
|
|
4
|
+
datasette_scan-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
+
datasette_scan-0.1.1.dist-info/entry_points.txt,sha256=fOaLPgQZHvLyW71-yajydDubd7OuYhmWRYQWpcyZIz8,34
|
|
6
|
+
datasette_scan-0.1.1.dist-info/top_level.txt,sha256=o-mz-kM1glO9fFLsNAnmZIemVErwj2JGmWnQtJdeyC4,15
|
|
7
|
+
datasette_scan-0.1.1.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
datasette_scan/__init__.py,sha256=ngXZCDSjZQnaJifobz-tWum0Zwof5NuzCTHdyLkB4Bg,5996
|
|
2
|
-
datasette_scan-0.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
3
|
-
datasette_scan-0.1.dist-info/METADATA,sha256=ywtSHF5EVjqTqIlvli5tJsvPbfeT-5dl8a9pUWcurRI,4208
|
|
4
|
-
datasette_scan-0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
-
datasette_scan-0.1.dist-info/entry_points.txt,sha256=fOaLPgQZHvLyW71-yajydDubd7OuYhmWRYQWpcyZIz8,34
|
|
6
|
-
datasette_scan-0.1.dist-info/top_level.txt,sha256=o-mz-kM1glO9fFLsNAnmZIemVErwj2JGmWnQtJdeyC4,15
|
|
7
|
-
datasette_scan-0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|