Add active checking

This commit is contained in:
Ivan Vazhenin
2023-09-18 19:32:13 +03:00
parent 361c346d8b
commit e0fdd25ca4
2 changed files with 40 additions and 1 deletions

10
db.py
View File

@@ -1,6 +1,6 @@
from datetime import datetime from datetime import datetime
from typing import List, Optional from typing import List, Optional
from sqlalchemy import create_engine, String, select, ForeignKey from sqlalchemy import create_engine, String, select, ForeignKey, Enum
from sqlalchemy.orm import Session, DeclarativeBase, Mapped, mapped_column, relationship from sqlalchemy.orm import Session, DeclarativeBase, Mapped, mapped_column, relationship
@@ -124,5 +124,13 @@ class Queue(Base):
} }
class Schemas(Base):
__tablename__ = 'schemas'
id: Mapped[int] = mapped_column(primary_key=True)
schema: Mapped[str]
schema_type: Mapped[str]
def connect_db(): def connect_db():
return create_engine("postgresql+psycopg://postgres:Root12345678@10.10.8.83:32101/db") return create_engine("postgresql+psycopg://postgres:Root12345678@10.10.8.83:32101/db")

31
init.py Normal file
View File

@@ -0,0 +1,31 @@
from db import Base, User, connect_db
from sqlalchemy.orm import Session
def init():
sync_engine = connect_db()
Base.metadata.drop_all(sync_engine)
Base.metadata.create_all(sync_engine)
with Session(sync_engine) as session:
bnd127 = User(
username="bnd127",
passwd="gost_2012$a742ec53198ec2a5027086fba8814a89982a57112d1a72d02260161108f39b50",
bndname="bnd127",
newbnd=True,
active=True,
upstream=False
)
bnd128 = User(
username="bnd128",
passwd="gost_2012$a742ec53198ec2a5027086fba8814a89982a57112d1a72d02260161108f39b50",
bndname="bnd128",
newbnd=True,
active=True,
upstream=False
)
session.add_all([bnd127, bnd128])
session.commit()
if __name__ == '__main__':
init()