-
First Check
Example Code# main.py
from fastapi import FastAPI
from dotenv import load_dotenv
import os
import sqlite3
def init_db():
with sqlite3.connect(os.environ.get("DB_URI", "tmp.db")) as conn:
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS my_table (
id INTEGER PRIMARY KEY,
email TEXT NOT NULL,
description TEXT NOT NULL,
created_at TIMESTAMP DEFAULT (DATETIME('now', 'localtime'))
)
""")
load_dotenv()
init_db()
app = FastAPI(title="My app")DescriptionIn my app, I initialize a SQLite database as shown above. Once deployed on FastAPI cloud, I added a few new records and can see the records as expected from another API endpoint (code not shown). But after leaving the application deployed for about a day or two, I can no longer see any records through my GET endpoint. When deployed locally on my dev machine, everything seems to be working fine. Operating SystemmacOS Operating System DetailsNo response FastAPI Version0.124.4 Pydantic Version2.12.5 FastAPI CLI Version0.0.16 Python Version3.13.6 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Thanks for the report! President storage is not yet supported, but it's in our roadmap. The reason why this currently happens is because FastAPI Cloud creates more replicas to handle more requests when they come, but those replicas don't have access to the same file system. The same would happen when there's no longer traffic, FastAPI Cloud would automatically reduce the number of live replicas. But persistent file storage is definitely in our roadmap. 🤓😎 |
Beta Was this translation helpful? Give feedback.
Thanks for the report!
President storage is not yet supported, but it's in our roadmap.
The reason why this currently happens is because FastAPI Cloud creates more replicas to handle more requests when they come, but those replicas don't have access to the same file system. The same would happen when there's no longer traffic, FastAPI Cloud would automatically reduce the number of live replicas.
But persistent file storage is definitely in our roadmap. 🤓😎