import sqlite3 import os from flask import Flask app = Flask(__name__) app.config['SECRET_KEY'] = 'your_secret_key' # Use the same key as in __init__.py instance_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../instance')) if not os.path.exists(instance_folder): os.makedirs(instance_folder) db_path = os.path.join(instance_folder, 'users.db') conn = sqlite3.connect(db_path) cursor = conn.cursor() # Create users table if not exists cursor.execute(''' CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE NOT NULL, password TEXT NOT NULL, role TEXT NOT NULL ) ''') # Insert superadmin user if not exists cursor.execute(''' INSERT OR IGNORE INTO users (username, password, role) VALUES (?, ?, ?) ''', ('superadmin', 'superadmin123', 'superadmin')) conn.commit() conn.close() print("Internal users.db seeded with superadmin user.")