Comments (5)
I think this is an alembic bug. @zzzeek?
from sqlalchemy-redshift.
alembic's autogenerate render does not currently render the info dictionary. SQLA itself doesn't use .info at all so is not part of what it needs to render column DDL. However, if redshift and other dialects are relying upon info for extra DDL hints, that is a supported case so alembic should support rendering .info. A fix for this though should include .info for everything, columns, tables, indexes, etc. It also should be careful not to barf if there are un-reprable things in that .info dictionary (as any application can put any kind of object in this dictionary), and perhaps even only render simple ints, strings and booleans from the dictionary. this would take place in alembic/autogenerate/render.py and of course be exercised in new unit tests in tests/test_autogen_render.py.
I would note that alembic allows user-defined rendering right now, which would allow redshift to supply a workaround if this was worth it, but it would have to define the whole Column render itself: http://alembic.zzzcomputing.com/en/latest/api/runtime.html#alembic.runtime.environment.EnvironmentContext.configure.params.render_item probably not worth it.
from sqlalchemy-redshift.
@DanCardin @graingert @zzzeek
If you are still having this need (or if some people have it in the future) of auto-generating the alembic migration script for some Redshift tables with columns encoding.
Indeed it is currently not possible using Alembic but there is a workaround : write the migration script manually as following (using the example given by DanCardin)
def upgrade():
from tables.models.example import Example
Example.__table__.create(bind=op.get_bind())
Using this trick you avoid Alembic's code generation and use directly the sqlalchemy-redshift adaptor which itself is aware of the info={'encode': 'lzo'}
field and will include it while creating the table.
from sqlalchemy-redshift.
from sqlalchemy-redshift.
Using @zzzeek 's suggested workaround, this renderer was sufficient for including info dicts in Redshift migrations.
def render_redshift_column(type_, col, autogen_context):
"""Render columns with info dicts for Redshift migrations."""
if type_ == "column":
render = "sa.Column("
render += "'{name}'".format(name=col.name)
render += ", sa.{coltype}".format(coltype=repr(col.type))
render += ", nullable={null}".format(null=str(col.nullable))
render += ", info={info})".format(info=str(col.info))
return render
else:
return False
from sqlalchemy-redshift.
Related Issues (20)
- Update project CI
- Regression causing errors during reflection for 1.4 FutureEngine HOT 5
- Log handler added in v0.8.13 produces duplicate logs in application
- Regression in v0.8.13: table reflection broken for non-superusers HOT 2
- Do not run integration tests with dbuser having elevated permissions HOT 1
- Migration error: 'Relation "alembic_version" already exists'
- Alembic migration issue: alter table
- Alembic migrations use RETURNING on update
- Performance degradation and memory peaks when updating from 0.8.12
- Class method needs updating HOT 1
- Table Reflection Slowness
- Temp Table Reflection
- Programming Error with percentile_cont HOT 1
- statements save OIDs unless commited
- Proposal: Remove pkg_resources from the fast path
- Any way to support sqlalchemy >= 2.0? HOT 3
- util.text_type issue HOT 1
- attach query group while running redshift queries
- Reflection does not populate primary key column if its name requres to be enclosed in double quotes
- sqlalchemy-redshift installing older SQLAlchemy version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlalchemy-redshift.