save errors in local db

This commit is contained in:
Lei PAN
2022-06-02 17:59:12 +02:00
parent f3694ef8ee
commit d13a96b984
5 changed files with 100 additions and 18 deletions
+43
View File
@@ -0,0 +1,43 @@
from sqlalchemy import Column, String, Integer, DateTime, func
from sqlalchemy.orm import declarative_base
import definitions
from pojo.contact_pojo import ContactPojo
Base = declarative_base()
ERROR_TYPE_CAPTCHA = 1
class ContactInErrorPojo(Base):
__tablename__ = "contacts_in_error"
mail: str = Column(String, primary_key=True)
phone: str = Column(String)
passport: str = Column(String)
last_name: str = Column(String)
first_name: str = Column(String)
ccid: str = Column(String)
position: int = Column(Integer)
error_type = Column(Integer)
update_at = Column(DateTime, onupdate=func.now())
create_at = Column(DateTime, default=func.now())
def get_captcha_error_contact_from_contact(contact: ContactPojo, error_type: int) -> ContactInErrorPojo:
captcha_error = ContactInErrorPojo()
captcha_error.mail = contact.mail
captcha_error.ccid = contact.ccid
captcha_error.phone = contact.phone
captcha_error.passport = contact.passport
captcha_error.first_name = contact.first_name
captcha_error.last_name = contact.last_name
captcha_error.position = contact.position
captcha_error.error_type = error_type
return captcha_error
if __name__ == '__main__':
conact = ContactPojo(mail="panleici3m@gmail.com", phone_number="649114592", ccid="", position=0,
passport_number="3322111", first_name="Lei", last_name="PAAaN")
definitions.local_db_manager.insert_or_update(get_captcha_error_contact_from_contact(conact, ERROR_TYPE_CAPTCHA))