-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_db_path.py
More file actions
50 lines (40 loc) · 1.7 KB
/
check_db_path.py
File metadata and controls
50 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
"""
Check the actual database path Flask is using.
"""
import os
from pathlib import Path
from config import Config
def check_paths():
"""Check database path resolution."""
print("Database Path Check")
print("==================")
config = Config()
print(f"Current working directory: {os.getcwd()}")
print(f"Config SQLITE_DB_PATH: {config.SQLITE_DB_PATH}")
print(f"Config SQLALCHEMY_DATABASE_URI: {config.SQLALCHEMY_DATABASE_URI}")
# Extract path from URI
uri = config.SQLALCHEMY_DATABASE_URI
if uri.startswith('sqlite:///'):
db_path = uri[10:] # Remove 'sqlite:///'
print(f"Extracted database path: {db_path}")
print(f"Is absolute: {os.path.isabs(db_path)}")
if not os.path.isabs(db_path):
full_path = os.path.join(os.getcwd(), db_path)
print(f"Full resolved path: {full_path}")
else:
full_path = db_path
print(f"Database file exists: {os.path.exists(full_path)}")
if os.path.exists(full_path):
print(f"File permissions: {oct(os.stat(full_path).st_mode)[-3:]}")
print(f"File readable: {os.access(full_path, os.R_OK)}")
print(f"File writable: {os.access(full_path, os.W_OK)}")
# Check parent directory
parent_dir = os.path.dirname(full_path)
print(f"Parent directory: {parent_dir}")
print(f"Parent exists: {os.path.exists(parent_dir)}")
if os.path.exists(parent_dir):
print(f"Parent readable: {os.access(parent_dir, os.R_OK)}")
print(f"Parent writable: {os.access(parent_dir, os.W_OK)}")
if __name__ == '__main__':
check_paths()