Questions tagged [sqlalchemy-migrate]

Schema migration tools for SQLAlchemy, designed to support an agile approach to database design, and make it easier to keep development and production databases in sync, as schema changes are required.

Inspired by Ruby on Rails’ migrations, SQLAlchemy Migrate provides a way to deal with database schema changes in SQLAlchemy projects. Migrate was started as part of Google’s Summer of Code by Evan Rosson, mentored by Jonathan LaCour. The project was taken over by a small group of volunteers when Evan had no free time for the project. It is now hosted as a Google Code project. During the hosting change the project was renamed to SQLAlchemy Migrate.

Python 2.4-2.7 is supported.

Resources:

97 questions
1
vote
1 answer

How to wrap create and sqlalchemy-migrate alter statments in a transaction

I'm trying some db schema changes to my db, using the sqlalchemy table.create and sqlalchemy-migrate table.rename methods, plus some insert into select statments. I want to wrap all of this in a transaction. I can't figure out how to do this. This…
Gary van der Merwe
  • 9,134
  • 3
  • 49
  • 80
1
vote
0 answers

SqlAlchemy, AttributeError: after_update

Hi guys I have 3 Tables (Traces, Components, Datasets) In the Traces table, I am trying to add an event where if the dataset_id is set to be NULL the active_columns will automatically be set to Null. this is the code I have: from datetime import…
Matan
  • 73
  • 2
  • 14
1
vote
2 answers

alembic autogenerates creates empty migration but generates table

I followed the documentation from Alembic to auto-generate migrations. My project structure looks like this: alembic/ versions/ env.py README script.py.mako data/ __init__.py db.py models.py alembic.ini app.db I made changes to env.py…
Tyrion
  • 405
  • 8
  • 22
1
vote
2 answers

SQLAlchemy Alembic: Issue with URL for SQLServer

I was trying to create a database migration script with Alembic for my SQLServer database and having issues with the connection string. This is what I have now: sqlalchemy.url = "mssql+pyodbc://db_server/database?trusted_connection=yes&driver=ODBC…
1
vote
0 answers

Alembic Migration for tables in SQLalchemy with index=true columns gives duplicate index error

My Previous Model: class sample(Base): __tablename__ = "sample" id = Column(BigInteger, primary_key=True,index=True) name = Column(String(30),index=True) My Latest Model: class sample(Base): __tablename__ = "sample" id =…
1
vote
1 answer

Fieldname modification in models SQLalchemy using ALEMBIC throws "Duplicate Column Name Error"

My Previous Model: class sample(Base): __tablename__ = "sample" id = Column(BigInteger, primary_key=True,index=True) Name = Column(String(30),index=True) My Latest Model: class sample(Base): __tablename__ = "sample" id =…
1
vote
1 answer

Stored procedure with Alembic: MySQL Syntax Error

I am using Alembic to load a stored procedure into the MySQL database. Following the cookbook, I was able to create the required objects for creating and dropping the procedure. Now that I want to upgrade the version to actually load the procedure,…
A23149577
  • 2,045
  • 2
  • 40
  • 74
1
vote
1 answer

SQLAlchemy migrations generating foreign keys with different names. How to drop these?

In my SQLAlchemy data model I had a reference from project->customer. I am doing migrations and initially this FK was created via sa.ForeignKeyConstraint(['customer_id'], ['customers.id'], ) (this was during the same migration that created the…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
1
vote
0 answers

Python migrations: No handlers could be found for logger "root"

I'm using Python with Flask, and I'm trying to migrate the database. I run flask db init and I get No handlers could be found for logger "root". Here is my main script: import os from flask_migrate import Migrate from app import create_app, db from…
scheebler
  • 15
  • 5
1
vote
0 answers

Subquery with SQLAlchemy with groupby and orderby

I am working on change my python code from db.engine.execute to proper SqlAlchmy manner, But I am stuck with a query having subquery with group_by and order_by. select * from (select * from table1 where value='a' or value='b' or value='c' order by…
Harsh Sharma
  • 10,942
  • 2
  • 18
  • 29
1
vote
1 answer

SQLAlchemy suggests table is missing a column that it has: ProgrammingError: (psycopg2.ProgrammingError) column Canada.address does not exist

I have four tables -- Users, Canada, France, Germany -- that are entirely independent. I have (I believe) added them to a database. But the columns of all the databases but Users seem to be unquery-able despite their being there. (One can query them…
1
vote
1 answer

Flask-Migration with one-to-many relationship

I have a working blog system. I want to add it to comment system. I completed migrations with post model with id, title and body. Now I add comments and create new model named Comment. When I run migrations: INFO [alembic.runtime.migration] Context…
1
vote
1 answer

How to inserting data into interrelated relationship tables using SQLAlchemy (not flask_sqlalchemy or flask-merge)?

I am new to SQLAlchemy, I am trying to build a practice project using SQLAlchemy. I have created the database containing tables with the following relationship. Now my questions are : How to INSERT data into the tables as they are…
Sunil
  • 429
  • 1
  • 9
  • 25
1
vote
0 answers

Flask-SQLAlchemy - how to add bind key to existing database

Due to additional data, I decided to reorganize the original SQLAlchemy database and start using multiple databases. Is there a way of changing the table name and adding a bind key to the original database? I searched through SQLAlchemy Migrate's…
1
vote
0 answers

Running SQLAlchemy-Migrate migration raises ValueError: too many values to unpack

When I try and run a SQLAlchemy-Migrate migration it gives me the following error: File "c:\users\achim\DOCUME~1\VISUAL~1\Projects\FFAWUZ\FFAWUZ\env\lib\site- packages\migrate\versioning\genmodel.py", line 219, in genB2AMigration for modelCol,…
Achim Munene
  • 538
  • 1
  • 5
  • 16