Show HN: SQLite-S3-query – Python function to query a SQLite database on S3
github.com
github.com
1. https://boto3.amazonaws.com/v1/documentation/api/latest/refe...
I can understand the AWS auth code... while there seem to be so many layers in boto3/botocore. There's a lot of code to add a few HTTP headers to each request. (It was a few years ago, but I posted about not using boto3 https://charemza.name/blog/posts/aws/python/you-might-not-ne...)
I might be suffering a little bit from not-invented-here syndrome admittedly... I don't know. But one of the things I really like about S3 is how much of its API is quite simple: it's just HTTP (I briefly wrote about _that_ as well https://charemza.name/blog/posts/http/s3/the-core-s3-api-is-...). My instinct is that in many cases, it's better to use a simple API directly rather than (what I see as) a more complex code base on top of it.
s3_client = boto3.client("s3")
class S3VFS:
def get_range(self, from_, to_):
return s3_client.get_object(..., Range=f'bytes={from_}-{to_}')['Body'].read()
with apsw.Connection(..., vfs=S3VFS())
That's drastically simpler, and safer to include from a library consumer point of view.I have now given them credit.
But I think there is a, or could be, a place for this:
- I don't think (but very happy to be corrected) that the things you mention can query SQLite files directly. So, there would have to be both a conversion of data, and then the query language used would not be SQLite's flavour of SQL. So, if you're using, or pro, using SQLite and wanting to keep the moving parts and languages down, then I _think_ there is a good argument for sqlite-s3-query to be used (with the caveat that it's a _very_ early version!)
- If you want, "light" dependency on AWS. There are a number of S3-compatible services that this could work on. Or even, the code could be tweaked to just use HTTP range headers, remove the dependency on versionId, which I think is only feature that makes this quite S3-specific. (Although, this would allow the case of errors/corruption if the database is replaced half way through a query...)
I use a SQLite database stored in S3 + SQLite's FTS5 for a really cheap full text search implementation.