MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / init_db

Function init_db

skills/storage-helper/scripts/db_ops.py:172–251  ·  view source on GitHub ↗

Initialize database, create all tables

()

Source from the content-addressed store, hash-verified

170
171
172def init_db() -> None:
173 """Initialize database, create all tables"""
174 conn = get_connection()
175 cursor = conn.cursor()
176
177 # Create profiles table
178 cursor.execute("""
179 CREATE TABLE IF NOT EXISTS profiles (
180 id INTEGER PRIMARY KEY AUTOINCREMENT,
181 user_id TEXT UNIQUE NOT NULL,
182 profile_json TEXT NOT NULL,
183 version TEXT NOT NULL,
184 updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
185 )
186 """)
187
188 # Create papers table
189 cursor.execute("""
190 CREATE TABLE IF NOT EXISTS papers (
191 id INTEGER PRIMARY KEY AUTOINCREMENT,
192 arxiv_id TEXT UNIQUE,
193 doi TEXT,
194 title TEXT NOT NULL,
195 authors TEXT,
196 institution TEXT,
197 abstract TEXT,
198 venue TEXT,
199 publish_date DATE,
200 embedding BLOB,
201 embedding_model TEXT,
202 fetched_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
203 pushed BOOLEAN DEFAULT FALSE,
204 push_date DATE
205 )
206 """)
207
208 # Create behavior_logs table
209 cursor.execute("""
210 CREATE TABLE IF NOT EXISTS behavior_logs (
211 id INTEGER PRIMARY KEY AUTOINCREMENT,
212 user_id TEXT NOT NULL,
213 push_id TEXT NOT NULL,
214 paper_id INTEGER,
215 action TEXT NOT NULL,
216 action_type TEXT NOT NULL,
217 category TEXT,
218 timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
219 metadata TEXT,
220 FOREIGN KEY (paper_id) REFERENCES papers(id)
221 )
222 """)
223
224 # Create task_status table
225 cursor.execute("""
226 CREATE TABLE IF NOT EXISTS task_status (
227 id INTEGER PRIMARY KEY AUTOINCREMENT,
228 task_id TEXT UNIQUE NOT NULL,
229 task_type TEXT NOT NULL,

Callers 3

mainFunction · 0.90
mainFunction · 0.90
db_ops.pyFile · 0.70

Calls 5

_create_chat_tablesFunction · 0.85
cursorMethod · 0.80
get_connectionFunction · 0.70
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected