Source: Sqlalchemy sqlite problems bd
← Renderedmarkdown source:
---
description: Ошибки миграции sqlite в alembic
tags: sqlalchemy python bd
title: Sqlalchemy sqlite problems bd
---
## При миграции с [[alembic]] выпадает ошибка "No support for ALTER of constraints in SQLite dialect"
В env.py алембика проставить:
```python
context.configure(
connection=connection,
target_metadata=target_metadata,
render_as_batch=True # <===this
)
```
[Ссылка на оверфло](https://stackoverflow.com/a/32510603)
Не помогло создать миграцию - надо ковырять `,ini`. Вариант решения - прописывать руками. [Статья](https://blog.miguelgrinberg.com/post/fixing-alter-table-errors-with-flask-migrate-and-sqlite).
Пример
```python
"""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]]
[alembic]: alembic "Alembic"
[sqlalchemy]: ../lists/sqlalchemy "Sqlalchemy"
[sqlite]: sqlite "Sqlite bd"