File size: 791 Bytes
ced61cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sqlite3

def create_auth_database():
    """Create authentication database if not exists"""
    try:
        conn = sqlite3.connect("./user_db/auth.db")
        cursor = conn.cursor()
        
        cursor.execute("""

            CREATE TABLE IF NOT EXISTS users (

                id INTEGER PRIMARY KEY AUTOINCREMENT,

                username TEXT UNIQUE NOT NULL,

                password_hash TEXT NOT NULL,

                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

            )

        """)
        
        conn.commit()
        conn.close()
        print("✅ Authentication database created successfully")
        
    except Exception as e:
        print(f"❌ Error creating auth database: {e}")

# Chạy function này
create_auth_database()