DB choice to set up credit balance stripe integration

Hello!

I am currently trying to set up a credit balance functionality on streamlit where users (which would then be checked and consumed when making an API call to e.g. an LLM provider). I also expect to deploy it on Streamlit Cloud.

More specifically, this means I need a database somewhere to store users’ credit balance information. So I’ve been looking into those and now feel like I’ve opened Pandora’s box :sweat_smile:.

I know I just need the most basic functionalities with simple read / write operations, and I expect very low activity.

It seems like SQLite hosted somewhere like S3 would be my best bet. However, S3 has no free tier (from what I can tell). The other option I was considering was Neon, which looked like an overkill for me at first but offers a free tier so why not I guess?

I was wondering if people had any guidance / advice / tips? I am trying to keep it as simple as possible (so I don’t waste time / money solving problems I do not have yet) but can’t shake the feeling I don’t have a complete picture yet.

Cheers!

My favorite choices for this have been:

  • Supabase (free tier is fine for small number of small projects, downside is it shuts down if you don’t use it for a while and you have to restart it)
  • SQLite Cloud (started trying this, seems like it works great, free tier is solid for my use-case, and it doesn’t shut down)

Neon also looks interesting, but I haven’t gotten a chance to test it out yet.

If you do end up using sqlite cloud, I didn’t end up st.connection with it (though it’s very possible I could, but I had a little trouble getting it all working)

import pandas as pd
import sqlitecloud
import streamlit as st

DB_NAME = "foo.db"


# Initialize connection.
@st.cache_resource
def init_connection() -> sqlitecloud.Connection:
    url = st.secrets["db_string"] # db_string = "sqlitecloud://....?apikey=..."
    conn = sqlitecloud.connect(url)
    conn.execute(f"USE DATABASE {DB_NAME}")
    return conn

Thanks a lot! Supabase does come up quite often in my research but I was afraid of how annoying the restarts could be. I had not heard of SQLite Cloud though and it does seem like exactly what I’m looking for right now! Will take a look, cheers!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.