How can I speed up fetching the results after running an sqlite query?

前端 未结 1 1112
感情败类
感情败类 2020-12-20 00:18

As an answer on my question: Is it normal that sqlite.fetchall() is so slow? it seems that fetch-all and fetch-one can be incredibly slow for sqlite.

As I mentioned

相关标签:
1条回答
  • 2020-12-20 01:02

    From reading this question, it sounds like you could benefit from using the APSW sqlite module. Somehow you may be victim of your sqlite module causing your query to be executed in some less performant manner.

    I was curious so I tried using apsw myself. It wasn't too complicated. Why don't you give it a try?

    To install it I had to:

    1. Extract the latest version.
    2. Have the installation package fetch the latest sqlite amalgamation.

      python setup.py fetch --sqlite
      
    3. Build and install.

      sudo python setup.py install
      
    4. Use it in place of the other sqlite module.

      import apsw
      <...>
      conn = apsw.Connection('foo.db')
      
    0 讨论(0)
提交回复
热议问题