Ревизии Alembic для IBM DB2 не работаютPython

Программы на Python
Ответить
Anonymous
 Ревизии Alembic для IBM DB2 не работают

Сообщение Anonymous »

Я собираюсь разработать веб -приложение, используя Flask и IBM DB для Z/OS. Как и сейчас я реализую с помощью колбы. Я попробовал с этим подходом ниже. Я установил Alembic, создал папку Alembic с его командой и внес некоторые изменения. Я запустил начальную команду файла миграции и сгенерировал файл версии, выполняя команду обновления Alembic, IOS не применяет какую -либо схему к DB. Я отлаживал и поместил в формате PDF в методе онлайн -миграции, и выполнение не приходит, что мне не хватает. версия/initial_migration.py
"""Initial migration

Revision ID: 41d53738262c
Revises:
Create Date: 2025-01-24 12:52:13.477580

"""
from alembic import op
import sqlalchemy as sa
# from src.utilities.all_envs import all_envs

# revision identifiers, used by Alembic.
revision = '41d53738262c'
down_revision = None
branch_labels = None
depends_on = None

def upgrade():
# Create the employee table
op.create_table(
'employee_table',
sa.Column('n_id', sa.Integer(), nullable=False),
sa.Column('v_name', sa.String(length=128), nullable=False),
sa.Column('v_description', sa.String(length=512), nullable=True),
sa.Column('v_other_names', sa.String(length=1024), nullable=True),

sa.PrimaryKeyConstraint('n_id'),
sa.UniqueConstraint('v_name'),
schema='sample_schema'
)

def downgrade():
op.drop_table('employee_table', schema='sample_schema')

это мой файл env.py перегонного куба.
from alembic import context
from sqlalchemy import create_engine, pool

def run_migrations_online():
# Retrieve the database URL from alembic.ini
config = context.config
url = config.get_main_option("sqlalchemy.url")

# Create an engine from the database URL
engine = create_engine(url, poolclass=pool.NullPool)

# Connect to the database
with engine.connect() as connection:
# Configure Alembic context without passing target_metadata
context.configure(
connection=connection
)

# Use the connection to begin migrations
with connection.begin():
context.run_migrations()

это мой alembic.ini
# A generic, single database configuration.

[alembic]
# path to migration scripts
script_location = alembic

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .

# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python-dateutil library that can be
# installed by adding `alembic[tz]` to the pip requirements
# string value is passed to dateutil.tz.gettz()
# leave blank for localtime
# timezone =

# max length of characters to apply to the
# "slug" field
# truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; This defaults
# to alembic/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator"
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions

# version path separator; As mentioned above, this is the character used to split
# version_locations. Valid values are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # default: use os.pathsep

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = ibm_db_sa://user:pwd@host:port/db

[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

Я пробую этот POC. Я могу создать первоначальный файл миграции с помощью команды пересмотра перегонного куба, и он сгенерировал файл версии. Но когда я пытаюсь выполнить команду обновления перегонного куба, она не применяет какие-либо таблицы к моей базе данных. Любая помощь здесь.
версии библиотек:
alembic==1.9.0

Flask==3.1.0
Flask-Cors==5.0.0
Flask-HTTPAuth==4.8.0
Flask-JWT-Extended==4.7.1
Flask-RESTful==0.3.10
flask-swagger-ui==4.11.1
greenlet==3.1.1
gunicorn==23.0.0
ibm_db==3.2.3
ibm_db_sa==0.4.1
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.0.0


Подробнее здесь: https://stackoverflow.com/questions/793 ... ot-working
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»