sqlalchemy-migrate

Stored procedure with Alembic: MySQL Syntax Error

旧城冷巷雨未停 提交于 2021-01-28 18:38:05
问题 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, I am getting SQL syntax near the DELIMITER $$ which I need for procedure definition. I have also tried to remove the DELIMITER and replace AS for starting the procedure, but that didn't work either. I even tried the simple example function in the

Flask-Migrate sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column

不打扰是莪最后的温柔 提交于 2020-07-18 04:02:29
问题 I am using Flask-Migrate in my application, with the following models: listpull/models.py from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id = db.Column(db.Integer, db.ForeignKey('listtype.id'), nullable=False) list_type = db.relationship('ListType', backref=db.backref('jobs', lazy='dynamic')) record_count = db.Column(db.Integer, nullable=False) status = db.Column(db.Integer, nullable=False) sf_job_id = db

How to alter column type from character varying to integer using sqlalchemy-migrate

◇◆丶佛笑我妖孽 提交于 2019-12-12 01:29:55
问题 I'm using sqlalchemy-migrate to alter the type of one of the columns in a table in a Postgre SQL database. The upgrade script I'm using is: # -*- cofing: utf-8 -*- from sqlalchemy import MetaData, Table, Column, String, Integer from migrate import changeset metadata = MetaData() def upgrade(migrate_engine): # ALTER TABLE courses ALTER COLUMN number SET DATA TYPE character varying; metadata.bind = migrate_engine courses = Table('courses', metadata, Column("number", Integer), extend_existing

One-to-one relationship in Flask

牧云@^-^@ 提交于 2019-12-11 16:51:42
问题 I'm trying to create a one-to-one relationship in Flask using SqlAlchemy. I followed this previous post and I created the classes like ones below: class Image(db.Model): __tablename__ = 'image' image_id = db.Column(db.Integer, primary_key = True) name = db.Column(db.String(8)) class Blindmap(db.Model): __tablename__ = 'blindmap' module_id = db.Column(db.Integer, primary_key = True) image_id = db.Column(db.Integer, ForeignKey('image.image_id')) Although it can migrate the model to the sqlite3

ERROR [alembic.env] name 'Text' is not defined upon 'python manage.py db upgrade'

余生长醉 提交于 2019-12-11 06:08:31
问题 Replicating this link to first test the feasibility of DB migration.. This turns out to be a bug in Alembic, and I tried adding from sqlalchemy.types import Text to no avail. This link is supposed to be a fix, but I cannot quite see which part of the code I can use for my purpose. from alembic import autogenerate from app import db import sqlalchemy as sa from sqlalchemy.dialects.postgresql import JSON from sqlalchemy import Integer, String, TIMESTAMP from sqlalchemy.types import Text class

sqlalchemy postgresql enum does not create type on db migrate

雨燕双飞 提交于 2019-12-03 10:46:07
问题 I develop a web-app using Flask under Python3. I have a problem with postgresql enum type on db migrate/upgrade. I added a column "status" to model: class Banner(db.Model): ... status = db.Column(db.Enum('active', 'inactive', 'archive', name='banner_status')) ... Generated migration by python manage.py db migrate is: from alembic import op import sqlalchemy as sa def upgrade(): op.add_column('banner', sa.Column('status', sa.Enum('active', 'inactive', 'archive', name='banner_status'), nullable

Cannot complete Flask-Migration

扶醉桌前 提交于 2019-12-03 07:11:56
问题 I've setup a local Postgres DB with SQLAlchemy and cannot commit my first entry. I keep on getting this error... ProgrammingError: (ProgrammingError) relation "user" does not exist LINE 1: INSERT INTO "user" (name, email, facebook_id, facebook_token... It seems like the fields aren't matching to those in the database. I'm trying to migrate using flask-migrate but, when I run $ python app.py db migrate I get this error... raise util.CommandError("No such revision '%s'" % id_) alembic.util

Is it worth using sqlalchemy-migrate ? [closed]

十年热恋 提交于 2019-12-03 05:25:45
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I have a web application using sqlalchemy (within Pylons). I need to effiently change the schema to be able to change the production version at least on a daily basis, maybe more, without losing the data. I have played a little bit with sqlalchemy-migrate over the week-end

alembic util command error can't find identifier

[亡魂溺海] 提交于 2019-12-03 02:39:00
问题 I'm trying to use alembic to handle local migrations on my project. It worked the first time, but then I needed to delete the folder and restart.(don't ask why, I just had to) I'm following this tutorial and I run the command python manage.py db init And it was ok. But when I try to run python manage.py db migrate I'm getting this error: alembic.util.CommandError: Can't locate revision identified by '31b8ab83c7d' Now, it seems that alembic is looking for a revision that doesn't exists anymore

Cannot complete Flask-Migration

依然范特西╮ 提交于 2019-12-02 20:49:09
I've setup a local Postgres DB with SQLAlchemy and cannot commit my first entry. I keep on getting this error... ProgrammingError: (ProgrammingError) relation "user" does not exist LINE 1: INSERT INTO "user" (name, email, facebook_id, facebook_token... It seems like the fields aren't matching to those in the database. I'm trying to migrate using flask-migrate but, when I run $ python app.py db migrate I get this error... raise util.CommandError("No such revision '%s'" % id_) alembic.util.CommandError: No such revision '39408d6b248d' It may be best to delete everything and start from scratch as