karpetrosyan / hishel

An elegant HTTP Cache implementation for HTTPX and HTTP Core.
https://hishel.com
BSD 3-Clause "New" or "Revised" License
158 stars 19 forks source link

Add SQL Storage #260

Open Avihais12344 opened 1 month ago

Avihais12344 commented 1 month ago

Hello,

I was wondering, why there's no General SQL Storage. So I have added it.

I have used SQLalchemy for the task, and for some weird reason, it doesn't work with trio (async backend), but I think we can still add it.

Thanks ahead for the help!

Avihais12344 commented 1 month ago

Also I need to add the remove functionality, i would add it. Please don't close this PR.

Avihais12344 commented 1 month ago

Now added the remove!

karpetrosyan commented 1 month ago

Hi! Thanks for this PR. It would be very useful to have a general SQL implementation as a storage option, but I think it will make our storage solutions more complicated to maintain. So, I suggest continuing with the existing storage options and introducing the new one as a separate library. I’d be happy to add related libraries to hishel's documentation.

Avihais12344 commented 1 month ago

Why do you think it would be more complicated to maintain? You already have many options, we can replace the sqlite one with this, and have more options like postgress, mysql and more. I think the maintenance is worth the cost. For some people, get SQL-ish DB is way easier then getting S3 or redis.

Avihais12344 commented 1 month ago

Finally it passes!