-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user.py
More file actions
27 lines (23 loc) · 903 Bytes
/
Copy pathcreate_user.py
File metadata and controls
27 lines (23 loc) · 903 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
import postgres
import click
# @click.command()
# @click.option('--username', help='Username')
# @click.option('--password', prompt='Your password that will be stored as text',
# help='Any password you wish it is unsafe anyway')
def create_user(username:str,password:str,groupename:str):
connection=postgres.get_connection()
cur=connection.cursor()
cur.execute("INSERT INTO users (username,password,groupid) VALUES (%s,%s, (SELECT groupid FROM usergroups WHERE groupname=%s))",(username,password,groupename))
success=connection.commit()
print(success)
connection.close()
return True
def delete_user(username):
connection=postgres.get_connection()
cur=connection.cursor()
cur.execute("DELETE FROM users WHERE username=%s",(username,))
connection.commit()
connection.close()
return True
# if __name__ == '__main__':
# create_user()