Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:12:10+00:00 2026-06-10T02:12:10+00:00

This example shows how to use it with non-declarative – http://docs.sqlalchemy.org/en/latest/core/ddl.html#sqlalchemy.schema.DDL How can I

  • 0

This example shows how to use it with “non-declarative” – http://docs.sqlalchemy.org/en/latest/core/ddl.html#sqlalchemy.schema.DDL

How can I use it with the ORM declarative syntax?

For example, with this structure:

Base = declarative_base(bind=engine)     
class TableXYZ(Base):
    __tablename__ = 'tablexyz'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:12:11+00:00Added an answer on June 10, 2026 at 2:12 am

    Silly example, but think this is what you’re looking for, should get you going:

    from sqlalchemy import event
    from sqlalchemy.engine import create_engine
    from sqlalchemy.ext.declarative import declarative_base
    from sqlalchemy.orm import create_session
    from sqlalchemy.schema import Column, DDL
    from sqlalchemy.types import Integer
    
    Base = declarative_base()
    engine = create_engine('sqlite:////tmp/test.db', echo=True)
    
    class TableXYZ(Base):
        __tablename__ = 'tablexyz'
        id = Column(Integer, primary_key=True)
    
    #event.listen(
    #   Base.metadata, 'after_create',
    #   DDL("""
    #   alter table TableXYZ add column name text
    #   """)
    
    event.listen(
        TableXYZ.__table__, 'after_create',
        DDL("""
        alter table TableXYZ add column name text
        """)
    )
    Base.metadata.create_all(engine)
    

    Running the above results in – note “name text” for the added column:

    sqlite> .schema tablexyz
    CREATE TABLE tablexyz (
        id INTEGER NOT NULL, name text, 
        PRIMARY KEY (id)
    );
    

    I have my code in declarative and use the event.listen to add triggers and other stored procedures. Seems to work well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This example shows what I am trying to do: http://jsfiddle.net/Dqjvy/ I would like it
I'm following this example: http://www.codinghorror.com/blog/2005/12/getting-started-with-indexing-service.html However, the conversion to dataset shows empty columns for
Currently, this example shows an unordered list with 8 list items in it. Is
This jsfiddle example shows what I'm talking about, I gave the div in question
The example on this page only shows Groovy assertions without parentheses. assert a !=
I've watched this video from Google I/O 2009: http://www.youtube.com/watch?v=AgaL6NGpkB8 where Brett shows microblogging example.
I'm trying to use Flash's StageVideo object through the example ActionScript file in this
So I'm having a bit of trouble understanding this example that was shown in
In this example my NSDictionary initializes with 0 key/value pairs, as shown in my
i don't understand this example from the doc : the timeIntervalSinceNow method should show

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.