mirror of
https://github.com/Zetaphor/browser-recall.git
synced 2025-12-06 10:29:38 +00:00
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
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() |