alembic

How to use Alembic with a SSL connection?

大兔子大兔子 提交于 2019-12-25 00:33:17
问题 I use Alembic to manage my migrations. My database is on AWS, and I want to connect it with SSL. In my alembic.ini I have the lines [production] script_location = alembic_prod sqlalchemy.url = mysql+pymysql://user:password@my-rds-host.eu-west-1.rds.amazonaws.com/mydatabase Of course, it works if user have the permission to connect the base without SSL, but not otherwise. How to require a SSL connection, and specify the certificate ? 回答1: You first need the certificate bundle - http://docs.aws

How can I migrate a table with data in a table which got a new datetime column which is non-nullable?

邮差的信 提交于 2019-12-24 19:25:15
问题 I've added a column registered_on = db.Column(db.DateTime, nullable=False) to my users table. The migration which was automatically created is def upgrade(): # ### commands auto generated by Alembic - please adjust! ### ... op.add_column('users', sa.Column('registered_on', sa.DateTime(), nullable=False)) ... When I execute it, I got an exception about an invalid value 0000-00-00 00:00:00 (or so). How should I adjust the migration script to not have this problem? (In this situation, filling in

How can I programmatically set the 'target_metadata' required by Alembic for use with the command API?

自作多情 提交于 2019-12-24 12:00:35
问题 I'm managing database migrations with Alembic and would like to use the default files generated by alembic init without any modifications to env.py (e.g., setting target_metadata) or alembic.ini (e.g., setting sqlalchemy.url) to manage migrations of my database from scripts. For example, I'd like to use a command based script like the following: import os from alembic.config import Config from alembic import command from myapp import db alembic_cfg = Config(os.path.join(os.path.abspath(os

Flask Migrate using different postgres schemas ( __table_args__ = {'schema': 'test_schema']})

一个人想着一个人 提交于 2019-12-24 02:04:47
问题 I'm trying to use flask, sqlalchemy, and flask_migrate... But every time run manage.py migrate, alembic always detect my model as a new table. I think that i put table_args in my model to store table in a different postgres schema: class Entry(db.Model): __table_args__ = {'schema': app.config['BASE_SCH']} id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100)) slug = db.Column(db.String(100), unique=True) body = db.Column(db.Text) status = db.Column(db.SmallInteger,

C++ Undefined symbol related to std::string in static lib

独自空忆成欢 提交于 2019-12-23 22:43:35
问题 I am building a shared lib by linking a bunch of code with a static lib (.a) on Linux in C++. I have a method defined in a static library. When I use nm -C to print the symbol in that static library is appears as: Alembic::AbcCoreFactory::v9::IFactory::getArchive(std::string const&, Alembic::AbcCoreFactory::v9::IFactory::CoreType&) The symbol is not defined in the output .so file (the library I am building), but when I list the undefined symbols using nm -uC it prints: Alembic::AbcCoreFactory

SQLAlchemy classical mapper “could not assemble any primary key columns for mapped table” despite presence of a primary key?

╄→гoц情女王★ 提交于 2019-12-23 10:51:12
问题 I'm working on a project with Alembic and SQLAlchemy, but I'm having trouble creating a simple entry in the database as a test. I get the following error: sqlalchemy.exc.ArgumentError: Mapper Mapper|Sale|sales_cache could not assemble any primary key columns for mapped table 'sales_cache' I've established the primary key (account_id) in both places below, any idea why SQLAlchemy doesn't recognize that or how to fix it? The other answers I've read have all dealt with exception cases for

sqlalchemy.exc.ArgumentError: Can't load plugin: sqlalchemy.dialects:driver

ぃ、小莉子 提交于 2019-12-23 06:47:11
问题 I am trying to run alembic migration and when I run alembic revision --autogenerate -m "Added initial tables" It fails saying sqlalchemy.exc.ArgumentError: Can't load plugin: sqlalchemy.dialects:driver the database url is postgresql+psycopg2://dev:passwd@localhost/db and I even have psycopg2 installed in my virtualenv $yolk -l Flask-Login - 0.1.3 - active Flask-SQLAlchemy - 0.16 - active Flask - 0.9 - active Jinja2 - 2.6 - active Mako - 0.7.3 - active MarkupSafe - 0.15 - active Python - 2.7.2

alembic create_table using declarative_base derived objects

半世苍凉 提交于 2019-12-22 11:37:23
问题 I have an Alchemy ORM object: from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class MyORM(Base): id = Column(Integer, primary_key=True) name = Column(String(128), unique=True, nullable=False) When using alembic to create the table I do the following: def upgrade(): op.create_table( 'myorm', sa.Column('id', sa.Integer, primary_key=True), sa.Column('name', sa.String(128), nullable=False), ) Question: Is there a way to use the MyORM class to create the table?

Trouble when using alembic with sqlalchemy_utils

时间秒杀一切 提交于 2019-12-22 08:11:09
问题 In my sqlalchemy model i use sqlalchemy_utils' choicetype: id = db.Column(db.Integer, primary_key=True) code = db.Column(db.Integer, nullable=True) level = db.Column(mytypes.types.ChoiceType(LEVEL)) I did everything as described here http://alembic.readthedocs.org/en/latest/autogenerate.html#autogen-module-prefix. In my model i imported choicetype from my module mytypes.types: from sqlalchemy_utils.types.choice import ChoiceType , in alembic/env.py i added context context.configure(

alembic and getting the last inserted value

时光毁灭记忆、已成空白 提交于 2019-12-21 05:34:13
问题 I'm using alembic to manage my database structure. After adding a table using id as Integer and primary key the id column will be an autoincrement-column. How do I query the data in the upgrade script so I'm sure that I get the correct id (I know it's 1 in this specific case)? I know how to #creating the table op.create_table( 'srv_feed_return_type', sa.Column('id', sa.Integer, primary_key=True), sa.Column('name', sa.String(50), nullable=False), sa.Column('created', sa.DateTime, server