-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdb_setup.py
More file actions
31 lines (26 loc) · 971 Bytes
/
db_setup.py
File metadata and controls
31 lines (26 loc) · 971 Bytes
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
"""
Database setup script for PDF Search Plus.
"""
import os
from pdf_search_plus.utils.db import PDFDatabase
def setup_database(db_name="pdf_data.db"):
"""
Set up the database with the latest schema.
Args:
db_name: Name of the database file to create
"""
# Remove existing database if it exists
if os.path.exists(db_name):
try:
os.remove(db_name)
print(f"Removed existing database: {db_name}")
except Exception as e:
print(f"Warning: Could not remove existing database: {e}")
# Create a new database with the latest schema
# Note: Explicitly passing db_name to support custom database names
# Other parts of the application use PDFDatabase() without arguments (relies on default)
db = PDFDatabase(db_name)
db.create_database()
print(f"Database {db_name} created successfully with the latest schema.")
if __name__ == "__main__":
setup_database()