Sqlalchemy sqlite problems bd
Теги: sqlalchemy python bd
При миграции с [alembic] выпадает ошибка “No support for ALTER of constraints in SQLite dialect”
В env.py алембика проставить:
context.configure(
connection=connection,
target_metadata=target_metadata,
render_as_batch=True # <===this
)
Не помогло создать миграцию - надо ковырять ,ini
. Вариант решения - прописывать руками. Статья.
Пример
"""remove a column
Revision ID: adfac8a1b2ee
Revises: 834b1a697901
Create Date: 2020-07-19 18:32:27.782197
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'adfac8a1b2ee'
down_revision = '834b1a697901'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_column('about_me')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('about_me', sa.VARCHAR(length=140), nullable=True))
# ### end Alembic commands ###
- [sqlalchemy]
- [sqlite]