-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit_db.py
More file actions
26 lines (23 loc) · 782 Bytes
/
init_db.py
File metadata and controls
26 lines (23 loc) · 782 Bytes
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
from app import app, db, User
from werkzeug.security import generate_password_hash
def init_db():
with app.app_context():
# Create all tables
db.create_all()
# Check if admin user exists
admin = User.query.filter_by(username='admin').first()
if not admin:
# Create admin user
admin = User(
username='admin',
password_hash=generate_password_hash('admin123'),
role='admin',
api_key='test_api_key_123456'
)
db.session.add(admin)
db.session.commit()
print("Admin user created successfully!")
else:
print("Admin user already exists!")
if __name__ == '__main__':
init_db()