Skip to content

Commit

Permalink
Merge pull request #989 from Pythagora-io/postgres
Browse files Browse the repository at this point in the history
postgresql support
  • Loading branch information
LeonOstrez authored Jun 3, 2024
2 parents 6b5c5c5 + 0e04cf3 commit 03b45bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ any adjustments if needed).

This will start two containers, one being a new image built by the `Dockerfile` and a Postgres database. The new image also has [ttyd](https://github.com/tsl0922/ttyd) installed so that you can easily interact with gpt-pilot. Node is also installed on the image and port 3000 is exposed.

### PostgreSQL support

GPT Pilot uses built-in SQLite database by default. If you want to use the PostgreSQL database, you need to additional install `asyncpg` and `psycopg2` packages:

```bash
pip install asyncpg psycopg2
```

Then, you need to update the `config.json` file to set `db.url` to `postgresql+asyncpg://<user>:<password>@<db-host>/<db-name>`.

# 🧑‍💻️ CLI arguments

Expand Down
6 changes: 6 additions & 0 deletions core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ class DBConfig(_StrictModel):
def validate_url_scheme(cls, v: str) -> str:
if v.startswith("sqlite+aiosqlite://"):
return v
if v.startswith("postgresql+asyncpg://"):
try:
import asyncpg # noqa: F401
except ImportError:
raise ValueError("To use PostgreSQL database, please install `asyncpg` and `psycopg2` packages")
return v
raise ValueError(f"Unsupported database URL scheme in: {v}")


Expand Down

0 comments on commit 03b45bd

Please sign in to comment.