Giter VIP home page Giter VIP logo

Comments (4)

olirice avatar olirice commented on June 16, 2024 1

sure

from sqlalchemy import Column, Integer, String, select
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class MyView(Base):
    __tablename__ = "my_view"

    __table_args__ = {
        "info": {"is_view": True},
    }

    id = Column(Integer, primary_key=True)
    name = Column(String)


print(MyView.__table__.info) # {'is_view': True}

I also wasn't able to find it in their docs. Might be worth opening an issue

from alembic_utils.

jack-michaud avatar jack-michaud commented on June 16, 2024 1

Great, thank you.
I had to customize the include_object function in the cookbook since PGView doesn't have an info attribute; my function looks like this and gets the desired result:

def include_object(object, name, type_, reflected, compare_to) -> bool:
    """
    Exclude views from Alembic's consideration (but includes alembic_utils' views)
    """
    if isinstance(object, ReplaceableEntity):
        return True
    return not object.info.get("is_view", False)

Thanks again for the help!

from alembic_utils.

olirice avatar olirice commented on June 16, 2024

Yeah, theres an entry for this in the alembic cookbook describing how to ignore tables

https://alembic.sqlalchemy.org/en/latest/cookbook.html#don-t-emit-create-table-statements-for-views

from alembic_utils.

jack-michaud avatar jack-michaud commented on June 16, 2024

For the life of me, I can't find how to add this info object to a declarative table. Do you have any insight @olirice?

from alembic_utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.