PythonSqliteAndPasswordHash

From Traxel Wiki
Jump to navigation Jump to search
from passlib.hash import bcrypt

import sqlite3

def register(email: str, password: str):
    conn = sqlite.connect('test01.db')
    cursor = conn.cursor()
    cursor.execute('''
    CREATE TABLE IF NOT EXISTS login (
      id INTEGER PRIMARY KEY,
      email TEXT,
      hash TEXT
    )
    ''')
    cursor.execute('''
    INSERT INTO login (email, hash)
    VALUES (?, ?)
    ''', (username, bcrypt.hash(password)))
    pass