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