Questions tagged [alembic]

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Some of the important operations that can be performed with alembic are

  • Upgrade(Perform Database migrations, Example: create/alter/modify)
  • Downgrade(Its the reverse operation of upgrade to undo the upgrade changes)
  • Current(Show the current revision and state of migration in the database)
  • Init(Initialize a new scripts directory)
  • Revision(Create a new revision file)

Related tags

References

854 questions
0
votes
1 answer

Alembic: How to print SQL for the last non-commited yet resivion in one command?

When I create migrations via Alembic, I want to check the result in SQL format. And the last only migration is interesting. alembic upgrade --sql head -- this command print SQL for all revisions It's possible to print SQL for the specific migrations…
Max Block
  • 1,134
  • 3
  • 16
  • 23
0
votes
0 answers

Can't db.drop_all() when creating tabes with SqlAlchemy op.create_table

I'm building a Flask service that uses SqlAlchemy Core for database operations, but I'm not using the ORM- just dispatching raw SQL to the PostgreSQL db. In order to track database migrations I'm using Alembic. My migration looks roughly like…
0
votes
1 answer

Two Python Flask App sharing same database drop table issue when running SQL Alchemy migrate command

I have built two flask app one for business (APP 1) and another one for admin (APP 2). Both APP 1 and APP 2 share same database and tables except APP 2 is using few subscriptions related tables which are not present in APP 1. Now the problem is…
0
votes
1 answer

ImportERROR: from . import postgresql, mysql, sqlite, mssql, oracle # pragma: no cover ImportError: cannot import name 'mysql'

I'm trying to use flask application on my web. I've installed Flask, Flask-Session, psycopg2-binary, and SQLAlchemy After that I try a simple code from flask from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): …
xenoveals
  • 9
  • 3
0
votes
1 answer

Alembic try to drop table after create table instead of before

I'm trying to migrate with Alembic. Env.py : from logging.config import fileConfig from sqlalchemy import engine_from_config from sqlalchemy import pool from alembic import context import sys import os sys.path.insert(0,…
Rayon Magique
  • 130
  • 2
  • 15
0
votes
1 answer

Adding column dynamically to an existing table using sqlalchemy, alembic

I want to add columns to a table in my database dynamically since I don't want to have to specify all columns when I set up the table in the SQLalchemy class In order to solve this I am using alembic to add columns to the table but I am having…
user12288003
  • 199
  • 1
  • 4
  • 14
0
votes
0 answers

Database dialect included in Alembic downgrade script, but not on upgrade script?

I am using alembic to generate database migration scripts for a mysql database. I've noticed that the syntax of the generated upgrade and downgrade scripts differ slightly, whereas I thought they would basically be the same. models.py-…
0
votes
1 answer

Alembic custom migation code doesn't work big query

I try this query in alembic migration code def get_my_table_id_list(connection): duplicate_id_list = connection.execute( """ SELECT a.id FROM my table AS a WHERE …
user9326232
0
votes
0 answers

Flask Sqlalchemy that works with postgres 9.6

I have been trying to deploy my flask application in a raspbian os environment. The application was running smoothly on ubuntu and postgres 11. On trying to run sqlalchemy migration i encountered error: undefined symbol: PQencryptPasswordConn. I…
Nix
  • 203
  • 1
  • 3
  • 14
0
votes
2 answers

How does it matter the schema defined using sqlalchemy, if Alembic has already defined the schema?

I'm using alembic for database migration. And using sqlalchemy to connect to the database using python. In alembic, we define table schema as the first version and this the actual one which creates the schema. For example, I have given schema like…
venkat
  • 453
  • 4
  • 16
0
votes
1 answer

Autogenerate alter_colum in op.batch_alter_table

I wrote an alembic comparator with @comparators.dispatch_for("table") to append a AlterColumnOp: modify_ops.ops.append( AlterColumnOp( table_name=tablename, column_name=column.name, …
bux
  • 7,087
  • 11
  • 45
  • 86
0
votes
1 answer

Flask - change the column type in existing database

I have following Model in existing db: class Advert(db.Model): id = db.Column(db.Integer, primary_key=True) date = db.Column(db.DateTime, nullable=False, default = datetime.utcnow) title = db.Column(db.String(100), nullable=False) …
cheng
  • 1
  • 3
0
votes
1 answer

Alembic - Create sequential migrations

My Git flow consists of develop, master and feature branches. I use Alembic for database migrations, and I run migrations only after merging branches into master. Currently, merging a branch containing migrations into develop causes trouble. Here is…
AdamGold
  • 4,941
  • 4
  • 29
  • 47
0
votes
1 answer

How to generate data in an Alembic migration i.e --autogenerate

I can successfully generate a database model, however I can't seem to figure out how to populate the database with data. I believe the error lies in the command I used to autogenerate alembic -x data=true upgrade head does not produce any data,…
Lukabratzee
  • 137
  • 1
  • 10
0
votes
1 answer

Flask Alembic migration error with geoalchemy2 - invalid geometry_type

I'm trying to implement Flask-Migrate to help manage migrations, but I get an error when trying to make the migration script: "geoalchemy2.exc.ArgumentError: invalid geometry_type 'POINTZ' for dimension 2". I have a Flask project and am using…