sqlite backend how to decode _content column? access the database parse raw _content? #955
-
it took about a day to create my cache and now i am just using sqlite to queery the data in the database. what is _content encoded as? gzip? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
nevermind, i would just think it would be nice to keeps backups of cahces database and access them without request_cache hitting to url again in case it was expired
|
Beta Was this translation helpful? Give feedback.
-
In PythonIf you want to access cached responses in python, use Example: from requests_cache import CachedSession
session = CachedSession()
r = session.get('https://httpbin.org/get')
for response in session.cache.responses.values():
print(response.content) See the cache inspection section of the docs for more details. In SQLFor querying the SQLite db directly (with only SQL), a few extra steps are needed:
session = CachedSession('http_cache_json.sqlite', serializer='json', decode_content=True)
r = session.get('https://httpbin.org/get') From a SELECT json_extract(value, '$._decoded_content') FROM responses; Or from the command line: sqlite3 http_cache_json.sqlite 'SELECT json_extract(value, \'$._decoded_content\') FROM responses;' Converting serialization formatsSee Exporting to a different backend if you want to convert your existing SQLite cache to this format. |
Beta Was this translation helpful? Give feedback.
nevermind, i would just think it would be nice to keeps backups of cahces database and access them without request_cache hitting to url again in case it was expired