Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.0 kB
5
Indexable
Never
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import sys
sys.path.append("..")
from models import User
from passlib.context import CryptContext


pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

engine = create_engine('postgresql://postgres:csieproj@localhost:7000')


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


new_users = [
    User(username='user1', password=pwd_context.hash('user1'),electricity_meter='admin',confirm_email=True),
    User(username='user2', password=pwd_context.hash('user2'),electricity_meter='test1', confirm_email=True),
    User(username='user3', password=pwd_context.hash('user3'),electricity_meter='test2', confirm_email=True),
    User(username='user4', password=pwd_context.hash('user4'),electricity_meter='test3', confirm_email=True),
    User(username='user5', password=pwd_context.hash('user5'),electricity_meter='test4', confirm_email=True)
]


session.add_all(new_users)


session.commit()


session.close()

Leave a Comment