33 lines
765 B
Python
Executable File
33 lines
765 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import demucs_server
|
|
|
|
import uuid
|
|
import IPython
|
|
|
|
with demucs_server.app.app_context():
|
|
|
|
def create_user(name: str) -> str:
|
|
db = demucs_server.db.get_db()
|
|
user_id = str(uuid.uuid4())
|
|
db.execute(
|
|
"INSERT INTO users (user_id, nickname) VALUES (?, ?)", [user_id, name]
|
|
)
|
|
db.commit()
|
|
|
|
return user_id
|
|
|
|
def list_users() -> list["demucs_server.auth.User"]:
|
|
from demucs_server.auth import User
|
|
|
|
db = demucs_server.db.get_db()
|
|
users = []
|
|
cur = db.execute("SELECT * FROM users")
|
|
for user_id, nickname in cur.fetchall():
|
|
users.append(User(uuid.UUID(user_id), nickname))
|
|
cur.close()
|
|
|
|
return users
|
|
|
|
IPython.embed()
|