-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
52 lines (42 loc) · 1.95 KB
/
Copy pathdatabase.py
File metadata and controls
52 lines (42 loc) · 1.95 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
51
52
import datetime
from sqlalchemy import create_engine, Column, Integer, String, DateTime, Text, ForeignKey, JSON
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship
Base = declarative_base()
class AgentStatus(Base):
__tablename__ = 'agents'
id = Column(Integer, primary_key=True)
name = Column(String, unique=True, nullable=False)
status = Column(String, default="OFFLINE") # OFFLINE, STARTING, ACTIVE, CRASHED, SLEEPING
last_seen = Column(DateTime, default=datetime.datetime.utcnow)
current_job_id = Column(String, nullable=True)
uptime_seconds = Column(Integer, default=0)
config = Column(JSON, nullable=True) # Per-agent configuration
class JobApplication(Base):
__tablename__ = 'job_applications'
id = Column(Integer, primary_key=True)
job_id = Column(String, nullable=False)
portal = Column(String, nullable=False)
title = Column(String)
company = Column(String)
status = Column(String) # APPLIED, FAILED, SKIPPED, PENDING
applied_at = Column(DateTime, default=datetime.datetime.utcnow)
details = Column(JSON) # Extra info like answers given, logs specific to this job
error_message = Column(Text, nullable=True)
class LogEntry(Base):
__tablename__ = 'logs'
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, default=datetime.datetime.utcnow)
agent_name = Column(String, nullable=False)
level = Column(String, nullable=False) # INFO, WARNING, ERROR, DEBUG
message = Column(Text, nullable=False)
module = Column(String)
# Database Engine Setup
DATABASE_URL = "sqlite:///./nowcurry_enterprise.db"
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def init_db():
Base.metadata.create_all(bind=engine)
if __name__ == "__main__":
init_db()
print("Database Initialized Architecturally.")