sqlite连接的正确类型?

MKe*_*per 2 python types type-hinting python-3.x

仍然是 Python 类型的新手,替换 ??? 的正确类型是什么?这里?

def update_sqlite(result: dict, db_connection: ???):
    pass

with sqlite3.connect('../data/Reports.db') as report_db:
    update_sqlite(result, report_db)
Run Code Online (Sandbox Code Playgroud)

Mar*_*rst 6

啊,你说的是PEP 484吗?正确的类型是sqlite3.Connection

  • 例如,对于光标,它将是 sqlite3.Cursor (3认同)