db.py 618 B

12345678910111213141516171819202122232425262728
  1. import os,sys,re,json
  2. # import mysql
  3. class Db():
  4. '''Db接口'''
  5. def __init__(self):
  6. pass
  7. def save(domain:str, res:bool):
  8. pass
  9. class File(Db):
  10. '''文件保存结果'''
  11. def save(self, filePath: str, res: str):
  12. # super().save(res)
  13. with open(filePath,'a+',encoding='utf-8') as file:
  14. file.writelines(res+"\n")
  15. class Mysql(Db):
  16. '''mysql数据库保存数据库'''
  17. def save(domain: str, res: bool):
  18. return super().save(res)
  19. class Sqlite(Db):
  20. '''sqlite保存'''
  21. def save(domain: str, res: bool):
  22. return super().save(res)