config.py 501 B

12345678910111213141516171819202122
  1. import pymysql
  2. from collections import namedtuple
  3. # database config type
  4. DbConf = namedtuple('DbConf', 'type, host, port, username, password, database, prefix, charset')
  5. conf = DbConf('mysql', '127.0.0.1', 3306, 'toor', '123456', 'twong', 'eb_', 'utf8mb4')
  6. conn = pymysql.connect(
  7. host=conf.host,
  8. port=conf.port,
  9. user=conf.username,
  10. password=conf.password,
  11. database=conf.database,
  12. charset=conf.charset,
  13. )
  14. # 表名
  15. def table(name:str) -> str:
  16. return conf.prefix + name