Initial commit

This commit is contained in:
2025-01-25 19:04:20 -06:00
commit d556823350
10 changed files with 334 additions and 0 deletions

38
app/database.py Normal file
View File

@@ -0,0 +1,38 @@
from sqlalchemy import create_engine, Column, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = "sqlite:///./browser_history.db"
engine = create_engine(SQLALCHEMY_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
class HistoryEntry(Base):
__tablename__ = "history_entries"
id = Column(Integer, primary_key=True, index=True)
url = Column(String, index=True)
title = Column(String, nullable=True)
visit_time = Column(DateTime, index=True)
domain = Column(String, index=True)
class Bookmark(Base):
__tablename__ = "bookmarks"
id = Column(Integer, primary_key=True, index=True)
url = Column(String, index=True)
title = Column(String, nullable=True)
added_time = Column(DateTime, index=True)
folder = Column(String, index=True)
domain = Column(String, index=True)
Base.metadata.create_all(bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()