-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.py
More file actions
executable file
·33 lines (24 loc) · 864 Bytes
/
Copy pathadmin.py
File metadata and controls
executable file
·33 lines (24 loc) · 864 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
27
28
29
30
31
32
33
import sqlalchemy as db
from sqlalchemy import text, insert, MetaData
from werkzeug.security import generate_password_hash, check_password_hash
def get_db_connection():
engine = db.create_engine(
"yourconnectionstring"
)
connection = engine.connect()
return connection
def generate_user():
email = "youremail"
password_cleartext = "yourpassword"
full_name = "Your Name"
password_hashed = generate_password_hash(password_cleartext)
conn = get_db_connection()
result = conn.execute(
text(
"INSERT INTO carrating.users (email, password, full_name) VALUES (:email, :password_hashed, :full_name)"
),
{"email": email, "password_hashed": password_hashed, "full_name": full_name},
)
conn.commit()
return result
print(generate_user())