I'm working for the first time with alembic and I want to insert data into a table after doing a migration.
This is my code
def upgrade():
acl_table = op.create_table('mqtt_acl',
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('allow', sa.Integer(), nullable=False),
sa.Column('ipaddr', sa.String(60), nullable=True),
sa.Column('username', sa.String(100), nullable=True),
sa.Column('clientid', sa.String(100), nullable=True),
sa.Column('access', sa.Integer(), nullable=True),
sa.Column('topic', sa.String(100), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_mqtt_acl'))
)
### end Alembic commands ###
op.bulk_insert(acl_table,
[
{
'id': 2,
'username': "USERNAME",
'clientid': "CLIENTID",
'allow': 1,
'access': 1,
'topic': '#',
}
]
)
Then I run alembic upgrade head
and it work's fine, doesn't return any error, but when I query the DB the data wasn't inserted and I can't figure out what's wrong.
I know the code is detected because if a make an invalid bulk_insert it gives me an invalid syntax error.
Can any one help me?