ShopBot/utils/database/ordering.py
2022-06-05 15:02:41 +03:00

25 lines
722 B
Python

from .model import UserInfo
def save_info(user_id: int, last_name:str, first_name:str, phone_number:str, address:str, **kw):
UserInfo.insert(
user_id=user_id,
first_name=first_name,
last_name=last_name,
phone_number=phone_number,
address=address
).on_conflict_replace().execute()
def get_info(user_id: int):
output = None
if UserInfo.select().where(UserInfo.user_id == user_id).exists():
user = UserInfo.get(UserInfo.user_id == user_id)
output = {
"last_name": user.last_name,
"first_name": user.first_name,
"phone_number": user.phone_number,
"address": user.address
}
return output