File size: 1,109 Bytes
53058d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from sqlalchemy import create_engine, text
from sqlalchemy.orm import sessionmaker

# Load configuration from .env
def get_db_url():
    env_path = "/Users/paritosh/Desktop/Jarvis/.env"
    if not os.path.exists(env_path):
        return None
    with open(env_path, "r") as f:
        for line in f:
            if line.startswith("DATABASE_URL="):
                return line.split("=")[1].strip().strip('"')
    return None

def check_remote_lock():
    url = get_db_url()
    if not url:
        print("Error: DATABASE_URL not found in .env")
        return

    engine = create_engine(url)
    Session = sessionmaker(bind=engine)
    session = Session()

    try:
        result = session.execute(text("SELECT key, value FROM kv_store WHERE key = 'safety_lock'")).fetchone()
        if result:
            print(f"DATABASE STATUS: {result[0]} = {result[1]}")
        else:
            print("DATABASE STATUS: safety_lock record NOT FOUND")
    except Exception as e:
        print(f"Database Error: {e}")
    finally:
        session.close()

if __name__ == "__main__":
    check_remote_lock()