update everything for psycopg 3.
This commit is contained in:
parent
2fdafbe7e4
commit
65fe82407f
@ -58,7 +58,7 @@ jobs:
|
||||
working-directory: ./reflex-web
|
||||
run: poetry run uv pip install -r requirements.txt
|
||||
- name: Install additional dependencies for DB access
|
||||
run: poetry run uv pip install psycopg2-binary
|
||||
run: poetry run uv pip install psycopg
|
||||
- name: Init Website for reflex-web
|
||||
working-directory: ./reflex-web
|
||||
run: poetry run reflex init
|
||||
|
4
.github/workflows/integration_tests.yml
vendored
4
.github/workflows/integration_tests.yml
vendored
@ -147,7 +147,7 @@ jobs:
|
||||
working-directory: ./reflex-web
|
||||
run: poetry run uv pip install $(grep -ivE "reflex " requirements.txt)
|
||||
- name: Install additional dependencies for DB access
|
||||
run: poetry run uv pip install psycopg2-binary
|
||||
run: poetry run uv pip install psycopg
|
||||
- name: Init Website for reflex-web
|
||||
working-directory: ./reflex-web
|
||||
run: poetry run reflex init
|
||||
@ -187,7 +187,7 @@ jobs:
|
||||
working-directory: ./reflex-web
|
||||
run: poetry run uv pip install -r requirements.txt
|
||||
- name: Install additional dependencies for DB access
|
||||
run: poetry run uv pip install psycopg2-binary
|
||||
run: poetry run uv pip install psycopg
|
||||
- name: Init Website for reflex-web
|
||||
working-directory: ./reflex-web
|
||||
run: poetry run reflex init
|
||||
|
@ -52,7 +52,7 @@ FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
RUN adduser --disabled-password --home /app reflex
|
||||
COPY --chown=reflex --from=init /app /app
|
||||
# Install libpq-dev for psycopg2 (skip if not using postgres).
|
||||
# Install libpq-dev for psycopg (skip if not using postgres).
|
||||
RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/*
|
||||
USER reflex
|
||||
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1
|
||||
|
@ -39,7 +39,7 @@ FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
RUN adduser --disabled-password --home /app reflex
|
||||
COPY --chown=reflex --from=init /app /app
|
||||
# Install libpq-dev for psycopg2 (skip if not using postgres).
|
||||
# Install libpq-dev for psycopg (skip if not using postgres).
|
||||
RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/*
|
||||
USER reflex
|
||||
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1
|
||||
|
@ -15,7 +15,7 @@ services:
|
||||
|
||||
app:
|
||||
environment:
|
||||
DB_URL: postgresql+psycopg2://postgres:secret@db/postgres
|
||||
DB_URL: postgresql+psycopg://postgres:secret@db/postgres
|
||||
REDIS_URL: redis://redis:6379
|
||||
depends_on:
|
||||
- db
|
||||
|
@ -82,7 +82,7 @@ class DBConfig(Base):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def postgresql_psycopg2(
|
||||
def postgresql_psycopg(
|
||||
cls,
|
||||
database: str,
|
||||
username: str,
|
||||
@ -90,7 +90,7 @@ class DBConfig(Base):
|
||||
host: str | None = None,
|
||||
port: int | None = 5432,
|
||||
) -> DBConfig:
|
||||
"""Create an instance with postgresql+psycopg2 engine.
|
||||
"""Create an instance with postgresql+psycopg engine.
|
||||
|
||||
Args:
|
||||
database: Database name.
|
||||
@ -103,7 +103,7 @@ class DBConfig(Base):
|
||||
DBConfig instance.
|
||||
"""
|
||||
return cls(
|
||||
engine="postgresql+psycopg2",
|
||||
engine="postgresql+psycopg",
|
||||
username=username,
|
||||
password=password,
|
||||
host=host,
|
||||
|
@ -164,7 +164,7 @@ def test_constructor_postgresql(username, password, host, port, database, expect
|
||||
"localhost",
|
||||
5432,
|
||||
"db",
|
||||
"postgresql+psycopg2://user:pass@localhost:5432/db",
|
||||
"postgresql+psycopg://user:pass@localhost:5432/db",
|
||||
),
|
||||
(
|
||||
"user",
|
||||
@ -172,17 +172,17 @@ def test_constructor_postgresql(username, password, host, port, database, expect
|
||||
"localhost",
|
||||
None,
|
||||
"db",
|
||||
"postgresql+psycopg2://user@localhost/db",
|
||||
"postgresql+psycopg://user@localhost/db",
|
||||
),
|
||||
("user", "", "", None, "db", "postgresql+psycopg2://user@/db"),
|
||||
("", "", "localhost", 5432, "db", "postgresql+psycopg2://localhost:5432/db"),
|
||||
("", "", "", None, "db", "postgresql+psycopg2:///db"),
|
||||
("user", "", "", None, "db", "postgresql+psycopg://user@/db"),
|
||||
("", "", "localhost", 5432, "db", "postgresql+psycopg://localhost:5432/db"),
|
||||
("", "", "", None, "db", "postgresql+psycopg:///db"),
|
||||
],
|
||||
)
|
||||
def test_constructor_postgresql_psycopg2(
|
||||
def test_constructor_postgresql_psycopg(
|
||||
username, password, host, port, database, expected_url
|
||||
):
|
||||
"""Test DBConfig.postgresql_psycopg2 constructor creates the instance correctly.
|
||||
"""Test DBConfig.postgresql_psycopg constructor creates the instance correctly.
|
||||
|
||||
Args:
|
||||
username: Database username.
|
||||
@ -192,10 +192,10 @@ def test_constructor_postgresql_psycopg2(
|
||||
database: Database name.
|
||||
expected_url: Expected database URL generated.
|
||||
"""
|
||||
db_config = DBConfig.postgresql_psycopg2(
|
||||
db_config = DBConfig.postgresql_psycopg(
|
||||
username=username, password=password, host=host, port=port, database=database
|
||||
)
|
||||
assert db_config.engine == "postgresql+psycopg2"
|
||||
assert db_config.engine == "postgresql+psycopg"
|
||||
assert db_config.username == username
|
||||
assert db_config.password == password
|
||||
assert db_config.host == host
|
||||
|
Loading…
Reference in New Issue
Block a user