Last active
April 6, 2020 17:10
-
-
Save anytizer/53c4350cae46e5e4bed76cd851938add to your computer and use it in GitHub Desktop.
Create an SQLite function: GUID()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import uuid | |
""" | |
CREATE TABLE "users" ( | |
"user_id" TEXT NOT NULL, | |
"user_email" TEXT NOT NULL UNIQUE, | |
"user_password" TEXT NOT NULL, | |
PRIMARY KEY("user_id") | |
); | |
""" | |
user = ["[email protected]", "pass1"] | |
conn = sqlite3.connect("cruder.db") | |
def guid(): | |
return str(uuid.uuid4()).upper() | |
conn.create_function("GUID", 0, guid) | |
cur = conn.cursor() | |
cur.execute("INSERT INTO users (user_id, user_email, user_password) VALUES (GUID(), ?, ?)", user) | |
conn.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import hashlib | |
import uuid | |
class provider(): | |
def __init__(self): | |
pass | |
def id(self): | |
return str(uuid.uuid4()).upper() | |
def now(self): | |
return str(datetime.datetime.now())[0:19] | |
def sha256(self, data): | |
secret = "seCretKeY" | |
return hashlib.sha256((data+secret).encode()).hexdigest().upper() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment