ETretyakov / hero-app

The Hero app is an example of ultimate setup for async web-service performance.
MIT License
93 stars 20 forks source link

Getting issue while running docker failing at alembic upgrade head #1

Closed pvssrikanth closed 2 years ago

pvssrikanth commented 2 years ago

Dear Sir, RUN alembic upgrade head ---> Running in abf1ce0bccc0 Traceback (most recent call last): File "/usr/local/bin/alembic", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 588, in main

KINDLY SUGGEST HOW TO RESOLVE THIS ISSUE

Thanks srikanth

ETretyakov commented 2 years ago

Hi!

It seems you have generated some new migration file, because I don't have any with such name - "abf1ce0bccc0". I believe it is located by this path "migrations/versions/abf1ce0bccc0.py".

So If you want me to help you, you need:

  1. to provide the content of your migration file "migrations/versions/abf1ce0bccc0.py";
  2. give me the whole log of the error.

Waiting for your response)

pvssrikanth commented 2 years ago

Dear Sir, Thanks for your prompt response and support.

Please find contents of the file pasted below

"""heroes

Revision ID: 886322ad66ff Revises: Create Date: 2022-05-21 18:06:29.571698

""" import sqlalchemy as sa import sqlmodel from alembic import op from sqlalchemy.dialects import postgresql

revision identifiers, used by Alembic.

revision = '886322ad66ff' down_revision = None branch_labels = None depends_on = None

def upgrade():

commands auto generated by Alembic - please adjust!

op.create_table('hrs_heroes',
sa.Column('role', postgresql.ENUM('mage', 'assassin', 'warrior',

'priest', 'tank', name='hrs_role'), nullable=True), sa.Column('uuid', sqlmodel.sql.sqltypes.GUID(), server_default=sa.text('gen_random_uuid()'), nullable=False), sa.Column('nickname', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('current_timestamp(0)'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('current_timestamp(0)'), nullable=False), sa.PrimaryKeyConstraint('uuid', name=op.f('pk_hrs_heroes')) ) op.create_index(op.f('ix_hrs_heroes_uuid'), 'hrs_heroes', ['uuid'], unique=True)

end Alembic commands

def downgrade():

commands auto generated by Alembic - please adjust!

op.drop_index(op.f('ix_hrs_heroes_uuid'), table_name='hrs_heroes')
op.drop_table('hrs_heroes')
# ### end Alembic commands ###

@.:~/srik/hero-app/migrations/versions$ ls 0001_886322ad66ff_heroes.py @.:~/srik/hero-app/migrations/versions$

-------------------------whole log of error pasted below

Sending build context to Docker daemon 254kB Step 1/10 : FROM python:3-slim-buster ---> 8addbbd4348f Step 2/10 : ARG ENV_FILE ---> Using cache ---> 2d1ae12000af Step 3/10 : ENV ENV_FILE=${ENV_FILE} PYTHONFAULTHANDLER=1 PYTHONUNBUFFERED=1 PYTHONHASHSEED=random PIP_NO_CACHE_DIR=off PIP_DISABLE_PIP_VERSION_CHECK=on PIP_DEFAULT_TIMEOUT=100 POETRY_VERSION=1.1.13 ---> Using cache ---> 46d7fdb1489e Step 4/10 : RUN pip install "poetry==$POETRY_VERSION" ---> Using cache ---> 62ba6ecc748c Step 5/10 : WORKDIR /vyce-backend ---> Using cache ---> 90bcd2b4f87e Step 6/10 : COPY poetry.lock pyproject.toml /vyce-backend/ ---> Using cache ---> e8daeb108606 Step 7/10 : RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi ---> Using cache ---> c62073e24125 Step 8/10 : COPY . /vyce-backend ---> Using cache ---> 18f14461e5e8 Step 9/10 : RUN alembic upgrade head ---> Running in 92f9f8940382 Traceback (most recent call last): File "/usr/local/bin/alembic", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 588, in main CommandLine(prog=prog).main(argv=argv) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 582, in main self.run_cmd(cfg, options) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 559, in run_cmd fn( File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 320, in upgrade script.run_env() File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 563, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 92, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 108, in load_module_py spec.loader.exec_module(module) # type: ignore File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/vyce-backend/migrations/env.py", line 27, in from app.heroes.models import Hero # noqa: 'autogenerate' support File "/vyce-backend/./app/init.py", line 9, in settings = Settings() File "pydantic/env_settings.py", line 38, in pydantic.env_settings.BaseSettings.init File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init pydantic.error_wrappers.ValidationError: 7 validation errors for Settings api_v1_prefix field required (type=value_error.missing) debug field required (type=value_error.missing) project_name field required (type=value_error.missing) version field required (type=value_error.missing) description field required (type=value_error.missing) db_async_connection_str field required (type=value_error.missing) db_async_test_connection_str field required (type=value_error.missing) The command '/bin/sh -c alembic upgrade head' returned a non-zero code: 1 @.***:~/srik/hero-app$

Thanking you for your help

Regards, srikanth

On Mon, Sep 12, 2022 at 9:21 PM Evgeniy Tretyakov @.***> wrote:

Hi!

It seems you have generated some new migration file, because I don't have any with such name - "abf1ce0bccc0". I believe it is located by this path "migrations/versions/abf1ce0bccc0.py".

So If you want me to help you, you need:

  1. to provide the content of your migration file "migrations/versions/abf1ce0bccc0.py";
  2. give me the whole log of the error.

Waiting for your response)

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1243940963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGUZKF5JDR42ZCMJRHXTV55GP7ANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>

ETretyakov commented 2 years ago

You have forgot to add .env file to the root of your repository, the content of the .env file should be like this:

# BASE
API_V1_PREFIX="/api/v1"
DEBUG=True
PROJECT_NAME="Heroes App (local)"
VERSION="0.1.0"
DESCRIPTION="The API for Heroes app."

# DATABASE
DB_ASYNC_CONNECTION_STR="postgresql+asyncpg://hero:heroPass123@0.0.0.0:5436/heroes_db"
DB_ASYNC_TEST_CONNECTION_STR="postgresql+asyncpg://hero:heroPass123@0.0.0.0:5436/heroes_db_tests"
DB_EXCLUDE_TABLES="[]"

Pay attention to the connection string it should comply with your database settings

pvssrikanth commented 2 years ago

Thanks Sir, For the guidance

But when i created .env

still getting issues

Step 9/10 : RUN alembic upgrade head ---> Running in 1e10484d0271 Traceback (most recent call last): File "/usr/local/bin/alembic", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 588, in main CommandLine(prog=prog).main(argv=argv) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 582, in main self.run_cmd(cfg, options) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 559, in run_cmd fn( File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 320, in upgrade script.run_env() File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 563, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 92, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 108, in load_module_py spec.loader.exec_module(module) # type: ignore File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/vyce-backend/migrations/env.py", line 27, in from app.heroes.models import Hero # noqa: 'autogenerate' support File "/vyce-backend/./app/init.py", line 9, in settings = Settings() File "pydantic/env_settings.py", line 38, in pydantic.env_settings.BaseSettings.init File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init pydantic.error_wrappers.ValidationError: 7 validation errors for Settings api_v1_prefix field required (type=value_error.missing) debug field required (type=value_error.missing) project_name field required (type=value_error.missing) version field required (type=value_error.missing) description field required (type=value_error.missing) db_async_connection_str field required (type=value_error.missing) db_async_test_connection_str field required (type=value_error.missing) The command '/bin/sh -c alembic upgrade head' returned a non-zero code: 1 @.***:~/srik/hero-app$

CAN you please guide if my .env which is pointing to postgresql another server configuration is wrong OR shall i install postgresql from here in this server. The command '/bin/sh -c alembic upgrade head' returned a non-zero code: 1 @.***:~/srik/hero-app$ cat .env

BASE

API_V1_PREFIX="/api/v1" DEBUG=True PROJECT_NAME="IIB App (local)" VERSION="0.1.0" DESCRIPTION="The API rest open api app."

DATABASE

DB_ASYNC_CONNECTION_STR="postgresql+asyncpg://

@.***:5436/heroes_db"

DB_ASYNC_TEST_CONNECTION_STR="postgresql+asyncpg://

@.***:5436/heroes_db_tests"

DB_EXCLUDE_TABLES="[]"

DB_ASYNC_CONNECTION_STR="postgresql+asyncpg:// @.:5432/heroes_db" DB_ASYNC_TEST_CONNECTION_STR="postgresql+asyncpg:// @.:5432/heroes_db_tests" DB_EXCLUDE_TABLES="[]" @.***:~/srik/hero-app$ Regards,

On Mon, Sep 12, 2022 at 11:46 PM Evgeniy Tretyakov @.***> wrote:

You have forgot to add .env file to the root of your repository, the content of the .env file should be like this:

BASE

API_V1_PREFIX="/api/v1" DEBUG=True PROJECT_NAME="Heroes App (local)" VERSION="0.1.0" DESCRIPTION="The API for Heroes app."

DATABASE

@.:5436/heroes_db" @.:5436/heroes_db_tests" DB_EXCLUDE_TABLES="[]"

Pay attention to the connection string it should comply with your database settings

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1244120313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGUZIV6OUGU3CH6B2JDDV55XORANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>

ETretyakov commented 2 years ago

Well, .env file looks fine.

The error related to the failure of reading environment variables by pydantic Settings. Do you run alembic upgrade head command from the project root directory?

pvssrikanth commented 2 years ago

No Sir Shall i run that command

I thought docker will take care

Shall i run it explicitly and followed with docker

Thanks for your guidance

On Tuesday, September 13, 2022, Evgeniy Tretyakov @.***> wrote:

Well, .env file looks fine.

The error related to the failure of reading environment variables by pydantic Settings. Do you run alembic upgrade head command from the project root directory?

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1245405483, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGU6Z7PWFL7BFMWE3OXTV6B5THANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>

ETretyakov commented 2 years ago

Ok, I see the problem.

Use this command to build Docker container: docker build --build-arg ENV_FILE=".env" -t hero-app -f Dockerfile . And this command to start container: docker run -d -p "8080:80" --name hero-app hero-app

Also pay attention to connection strings, i.e. on Mac OSX database on localhost would look like this: postgresql+asyncpg://hero:heroPass123@host.docker.internal:5436/heroes_db

pvssrikanth commented 2 years ago

Thanks for the Reply sir,

when i ran docker command

I am getting following error • Installing markupsafe (2.1.1)

OSError

Could not find a suitable TLS CA certificate bundle, invalid path: /usr/local/lib/python3.10/site-packages/certifi/cacert.pem

at /usr/local/lib/python3.10/site-packages/requests/adapters.py:263 in cert_verify 259│ if not cert_loc: 260│ cert_loc = extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH) 261│ 262│ if not cert_loc or not os.path.exists(cert_loc): → 263│ raise OSError( 264│ f"Could not find a suitable TLS CA certificate bundle, " 265│ f"invalid path: {cert_loc}" 266│ ) 267│

• Updating packaging (20.9 -> 21.3) • Installing pluggy (1.0.0) • Installing py (1.11.0) • Installing tomli (2.0.1) • Installing typing-extensions (4.2.0) The command '/bin/sh -c poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi' returned a non-zero code: 1

AND I went creating env3.8 and tried

(env) @.:~/srik/hero-app$ alembic upgrade head Traceback (most recent call last): File "/usr/bin/alembic", line 11, in load_entry_point('alembic==1.1.0.dev0', 'console_scripts', 'alembic')() File "/usr/lib/python3/dist-packages/alembic/config.py", line 540, in main CommandLine(prog=prog).main(argv=argv) File "/usr/lib/python3/dist-packages/alembic/config.py", line 534, in main self.run_cmd(cfg, options) File "/usr/lib/python3/dist-packages/alembic/config.py", line 511, in run_cmd fn( File "/usr/lib/python3/dist-packages/alembic/command.py", line 279, in upgrade script.run_env() File "/usr/lib/python3/dist-packages/alembic/script/base.py", line 475, in run_env util.load_python_file(self.dir, "env.py") File "/usr/lib/python3/dist-packages/alembic/util/pyfiles.py", line 98, in load_python_file module = load_module_py(module_id, path) File "/usr/lib/python3/dist-packages/alembic/util/compat.py", line 174, in load_module_py spec.loader.exec_module(module) File "", line 848, in exec_module File "", line 219, in _call_with_frames_removed File "/home/srikanth/srik/hero-app/migrations/env.py", line 8, in from sqlalchemy.ext.asyncio import AsyncEngine ModuleNotFoundError: No module named 'sqlalchemy.ext.asyncio' (env) @.:~/srik/hero-app$

Kindly advise what next to do

Thanking you srikanth

On Tue, Sep 13, 2022 at 9:15 PM Evgeniy Tretyakov @.***> wrote:

Ok, I see the problem.

Use this command to build Docker container: docker build --build-arg ENV_FILE=".env" -t hero-app -f Dockerfile . And this command to start container: docker run -d -p "8080:80" --name hero-app hero-app

Also pay attention to connection strings, i.e. on Mac OSX database on localhost would look like this: @.***:5436/heroes_db

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1245600941, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGU4QRKGOJH22T25IFITV6CORTANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>

pvssrikanth commented 2 years ago

Dear Sir, Step 9/10 : RUN alembic upgrade head ---> Running in 5c2793a8b21f Traceback (most recent call last): File "/usr/local/bin/alembic", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 588, in main CommandLine(prog=prog).main(argv=argv) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 582, in main self.run_cmd(cfg, options) File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 559, in run_cmd fn( File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 320, in upgrade script.run_env() File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 563, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 92, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 108, in load_module_py spec.loader.exec_module(module) # type: ignore File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/vyce-backend/migrations/env.py", line 97, in asyncio.run(run_migrations_online()) File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/vyce-backend/migrations/env.py", line 88, in run_migrations_online async with connectable.connect() as connection: File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/base.py", line 60, in aenter return await self.start(is_ctxmanager=True) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/engine.py", line 155, in start await (greenlet_spawn(self.sync_engine.connect)) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 126, in greenlet_spawn result = context.throw(sys.exc_info()) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/future/engine.py", line 406, in connect return super(Engine, self).connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3234, in connect return self._connection_cls(self, close_with_result=close_with_result) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in init else engine.raw_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3313, in raw_connection return self._wrap_pool_connect(self.pool.connect, _connection) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3280, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 310, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 868, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 476, in checkout rec = pool._do_get() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 256, in _do_get return self._create_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 256, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 371, in init self.connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 665, in connect with util.safereraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in exit compat.raise( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 207, in raise_ raise exception File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 661, in __connect self.dbapi_connection = connection = pool._invoke_creator(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 590, in connect return dialect.connect(cargs, cparams) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 597, in connect return self.dbapi.connect(*cargs, *cparams) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 777, in connect await_only(self.asyncpg.connect(arg, kw)), File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only return current.driver.switch(awaitable) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn value = await result File "/usr/local/lib/python3.10/site-packages/asyncpg/connection.py", line 2085, in connect return await connect_utils._connect( File "/usr/local/lib/python3.10/site-packages/asyncpg/connect_utils.py", line 881, in _connect return await _connect_addr( File "/usr/local/lib/python3.10/site-packages/asyncpg/connect_utils.py", line 790, in _connect_addr return await __connect_addr(params_retry, timeout, False, *args) File "/usr/local/lib/python3.10/site-packages/asyncpg/connect_utils.py", line 831, in __connect_addr await compat.wait_for(connected, timeout=timeout) File "/usr/local/lib/python3.10/site-packages/asyncpg/compat.py", line 66, in wait_for return await asyncio.wait_for(fut, timeout) File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for return fut.result() asyncpg.exceptions.InvalidPasswordError: password authentication failed for user "postgres" The command '/bin/sh -c alembic upgrade head' returned a non-zero code: 1 (env) @.***:~/srik/hero-app$

However from dbadmin I WAS ABLE TO connect DB

[image: image.png]

Kindly help me resolve this error

Thanking you

On Tue, Sep 13, 2022 at 9:24 PM Srikanth Pokkuluri @.***> wrote:

Thanks for the Reply sir,

when i ran docker command

I am getting following error • Installing markupsafe (2.1.1)

OSError

Could not find a suitable TLS CA certificate bundle, invalid path: /usr/local/lib/python3.10/site-packages/certifi/cacert.pem

at /usr/local/lib/python3.10/site-packages/requests/adapters.py:263 in cert_verify 259│ if not cert_loc: 260│ cert_loc = extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH) 261│ 262│ if not cert_loc or not os.path.exists(cert_loc): → 263│ raise OSError( 264│ f"Could not find a suitable TLS CA certificate bundle, " 265│ f"invalid path: {cert_loc}" 266│ ) 267│

• Updating packaging (20.9 -> 21.3) • Installing pluggy (1.0.0) • Installing py (1.11.0) • Installing tomli (2.0.1) • Installing typing-extensions (4.2.0) The command '/bin/sh -c poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi' returned a non-zero code: 1

AND I went creating env3.8 and tried

(env) @.***:~/srik/hero-app$ alembic upgrade head Traceback (most recent call last): File "/usr/bin/alembic", line 11, in load_entry_point('alembic==1.1.0.dev0', 'console_scripts', 'alembic')() File "/usr/lib/python3/dist-packages/alembic/config.py", line 540, in main CommandLine(prog=prog).main(argv=argv) File "/usr/lib/python3/dist-packages/alembic/config.py", line 534, in main self.run_cmd(cfg, options) File "/usr/lib/python3/dist-packages/alembic/config.py", line 511, in run_cmd fn( File "/usr/lib/python3/dist-packages/alembic/command.py", line 279, in upgrade script.run_env() File "/usr/lib/python3/dist-packages/alembic/script/base.py", line 475, in run_env util.load_python_file(self.dir, "env.py") File "/usr/lib/python3/dist-packages/alembic/util/pyfiles.py", line 98, in load_python_file module = load_module_py(module_id, path) File "/usr/lib/python3/dist-packages/alembic/util/compat.py", line 174, in load_module_py spec.loader.exec_module(module) File "", line 848, in exec_module File "", line 219, in _call_with_frames_removed File "/home/srikanth/srik/hero-app/migrations/env.py", line 8, in

from sqlalchemy.ext.asyncio import AsyncEngine ModuleNotFoundError: No module named 'sqlalchemy.ext.asyncio' (env) ***@***.***:~/srik/hero-app$ Kindly advise what next to do Thanking you srikanth On Tue, Sep 13, 2022 at 9:15 PM Evgeniy Tretyakov < ***@***.***> wrote: > Ok, I see the problem. > > Use this command to build Docker container: docker build --build-arg > ENV_FILE=".env" -t hero-app -f Dockerfile . > And this command to start container: docker run -d -p "8080:80" --name > hero-app hero-app > > Also pay attention to connection strings, i.e. on Mac OSX database on > localhost would look like this: > ***@***.***:5436/heroes_db > > — > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
ETretyakov commented 2 years ago

Please tell me what OS do you use, and where is your database located (local, docker, external)?

pvssrikanth commented 2 years ago

Dear Sir, I am using ubuntu20.2 details below @.:~/srik/hero-app$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS" @.:~/srik/hero-app$

and I have installed locally Postgresql using docker , details below

[sudo] password for srikanth: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1aeb8cd5d93b dpage/pgadmin4 "/entrypoint.sh" 12 hours ago Up 12 hours 443/tcp, 0.0.0.0:5050->80/tcp, :::5050->80/tcp pgadmin_container 976b00b5bfe9 postgres "docker-entrypoint.s…" 12 hours ago Up 12 hours 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp postgres_container @.***:~/srik/hero-app$

and contents of .env is below where i pointed to the localhost

@.***:~/srik/hero-app$ cat .env

BASE

API_V1_PREFIX="/api/v1" DEBUG=True PROJECT_NAME="IIB App (local)" VERSION="0.1.0" DESCRIPTION="The API rest open api app."

DATABASE

DB_ASYNC_CONNECTION_STR="postgresql+asyncpg://

@.***:5436/heroes_db"

DB_ASYNC_TEST_CONNECTION_STR="postgresql+asyncpg://

@.***:5436/heroes_db_tests"

DB_EXCLUDE_TABLES="[]"

DB_ASYNC_CONNECTION_STR="postgresql+asyncpg:// @.:5432/postgres" DB_ASYNC_TEST_CONNECTION_STR="postgresql+asyncpg:// @.:5432/postgres" DB_EXCLUDE_TABLES="[]" @.***:~/srik/hero-app$

Please help in resolving this issue.

AND one Technical query, Assume i have postgresql database with tables populated by another python-django webapplication.

AND i want to create a fastapi on specific table pointing enabling CRUD operations, any thoughts sir , is it easy to do or redesign completely and load table once again.

Thanks again for your kind support to me.

Regards, srikanth

On Wed, Sep 14, 2022 at 12:30 AM Evgeniy Tretyakov @.***> wrote:

Please tell me what OS do you use, and where is your database located (local, docker, external)?

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1245838507, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGUZESHUMDINR2G452P3V6DFOFANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>

ETretyakov commented 2 years ago
  1. You have opened port 5432 in docker for your database, and 5436 in your .env file, so you need 5432 in your .env file. So the lines should look like this: DB_ASYNC_CONNECTION_STR="postgresql+asyncpg://{your_user}:{your_password}@localhost:5432/heroes_db"
  2. As I understand your issue - you have another app with tables and data in it and you want to migrate the service to fastapi. So you need to create app with fastapi with all tables and then migrate your data from Django database to a new one with.
pvssrikanth commented 2 years ago

Thanks Sir For your guidance reply I will try and revert

Thanks for your kind support Regards Srikanth

On Wednesday, September 14, 2022, Evgeniy Tretyakov < @.***> wrote:

  1. You have opened port 5432 in docker for your database, and 5436 in your .env file, so you need 5432 in your .env file. So the lines should look like this: DB_ASYNC_CONNECTION_STR=" postgresql+asyncpg://{your_user}:{your_password}@ localhost:5432/heroes_db"
  2. As I understand your issue - you have another app with tables and data in it and you want to migrate the service to fastapi. So you need to create app with fastapi with all tables and then migrate your data from Django database to a new one with.

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1246710534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGU2V4KEZAUO3X2A6MI3V6HCB3ANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>

pvssrikanth commented 2 years ago

Dear Sir, Still facing issue @.:~/srik/hero-app$ docker run d47c154c24f8 Traceback (most recent call last): File "/usr/local/bin/uvicorn", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return callback(*args, kwargs) File "/usr/local/lib/python3.10/site-packages/uvicorn/main.py", line 437, in main run(app, kwargs) File "/usr/local/lib/python3.10/site-packages/uvicorn/main.py", line 463, in run server.run() File "/usr/local/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/usr/local/lib/python3.10/site-packages/uvicorn/server.py", line 67, in serve config.load() File "/usr/local/lib/python3.10/site-packages/uvicorn/config.py", line 458, in load self.loaded_app = import_from_string(self.app) File "/usr/local/lib/python3.10/site-packages/uvicorn/importer.py", line 21, in import_from_string module = importlib.import_module(module_str) File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 992, in _find_and_load_unlocked File "", line 241, in _call_with_frames_removed File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/vyce-backend/./app/init.py", line 9, in settings = Settings() File "pydantic/env_settings.py", line 38, in pydantic.env_settings.BaseSettings.init File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init__ pydantic.error_wrappers.ValidationError: 7 validation errors for Settings api_v1_prefix field required (type=value_error.missing) debug field required (type=value_error.missing) project_name field required (type=value_error.missing) version field required (type=value_error.missing) description field required (type=value_error.missing) db_async_connection_str field required (type=value_error.missing) db_async_test_connection_str field required (type=value_error.missing) *@.:~/srik/hero-app$ vi Dockerfile

I have corrected the database configuration file and was able to connect the PGADMIN database GUI

@.***:~/srik/hero-app$ cat .env

BASE

API_V1_PREFIX="/api/v1" DEBUG=True PROJECT_NAME="IIB App (local)" VERSION="0.1.0" DESCRIPTION="The API rest open api app."

DB_ASYNC_CONNECTION_STR="postgresql+asyncpg:// @.:5432/heroes_db" DB_ASYNC_TEST_CONNECTION_STR="postgresql+asyncpg:// @.:5432/heroes_db" DB_EXCLUDE_TABLES="[]" @.***:~/srik/hero-app$

Please advice.

Regards,

On Mon, Sep 12, 2022 at 9:21 PM Evgeniy Tretyakov @.***> wrote:

Hi!

It seems you have generated some new migration file, because I don't have any with such name - "abf1ce0bccc0". I believe it is located by this path "migrations/versions/abf1ce0bccc0.py".

So If you want me to help you, you need:

  1. to provide the content of your migration file "migrations/versions/abf1ce0bccc0.py";
  2. give me the whole log of the error.

Waiting for your response)

— Reply to this email directly, view it on GitHub https://github.com/ETretyakov/hero-app/issues/1#issuecomment-1243940963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGAGUZKF5JDR42ZCMJRHXTV55GP7ANCNFSM6AAAAAAQKNJFFU . You are receiving this because you authored the thread.Message ID: @.***>