-
First Check
Commit to Help
Example Code
DescriptionI want to use sqlite instead Pstgresql, can you help me to replace it in the backend. Operating SystemWindows Operating System Detailswindows 10 Python Versionpython 3.11 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
bwithai
Aug 22, 2025
Replies: 2 comments 1 reply
-
@tiangolo I imagine there is a simple way to remplace Postgresql by sqlite ! |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi @auh83 SQLITE_DB_FILE: str = ""
@computed_field # type: ignore[prop-decorator]
@property
def SQLALCHEMY_DATABASE_URI(self) -> str | PostgresDsn:
if self.SQLITE_DB_FILE:
return f"sqlite:///{self.SQLITE_DB_FILE}"
else:
return MultiHostUrl.build(
scheme="postgresql+psycopg",
username=self.POSTGRES_USER,
password=self.POSTGRES_PASSWORD,
host=self.POSTGRES_SERVER,
port=self.POSTGRES_PORT,
path=self.POSTGRES_DB,
) and in your .env file |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YuriiMotov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @auh83
Edit SQLALCHEMY_DATABASE_URI with this code
and in your .env file
SQLITE_DB_FILE=my_db.sqlite
-->python backend\app\initial_data.py