db.py 710 B

1234567891011121314151617181920212223242526
  1. import conf
  2. from .base_db import DBBit, DBException, DBCloseException, DBDataException, DBDoneException # 导入必要的内容
  3. if conf.database.upper() == 'MYSQL':
  4. try:
  5. from .mysql_db import MysqlDB
  6. except ImportError:
  7. print("Can not import mysqlDB")
  8. raise
  9. else:
  10. DB = MysqlDB
  11. else:
  12. print(f"Not support database: {conf.database}")
  13. raise Exception
  14. def search_from_garbage_checker_user(columns, where, db: DB):
  15. if len(where) > 0:
  16. where = f"WHERE {where} "
  17. column = ", ".join(columns)
  18. cur = db.search(f"SELECT {column} FROM garbage_checker_user {where};")
  19. if cur is None:
  20. return None
  21. res = cur.fetchall()
  22. return res