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 8177033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:24:22+00:00 2026-06-06T23:24:22+00:00

What I am trying to do is to get from SqlAlchemy entity definition all

  • 0

What I am trying to do is to get from SqlAlchemy entity definition all it’s Column()’s, determine their types and constraints, to be able to pre-validate, convert data and display custom forms to user.

How can I introspect it?

Example:

class Person(Base):
    '''
        Represents Person
    '''
    __tablename__ = 'person'

    # Columns
    id = Column(String(8), primary_key=True, default=uid_gen)
    title = Column(String(512), nullable=False)
    birth_date = Column(DateTime, nullable=False)

I want to get this id, title, birth date, determine their restrictions (such as title is string and max length is 512 or birth_date is datetime etc)

Thank you

  • 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-06T23:24:23+00:00Added an answer on June 6, 2026 at 11:24 pm

    If you are using sqlalchemy 0.8, then you should check out the new feature New Class Inspection System. Sample code extract from the documentation:

    class User(Base):
        __tablename__ = 'user'
    
        id = Column(Integer, primary_key=True)
        name = Column(String)
        name_syn = synonym(name)
        addresses = relationship(Address)
    
    # universal entry point is inspect()
    >>> b = inspect(User)
    
    # column collection
    >>> b.columns
    [<id column>, <name column>]
    

    Otherwise, see Accessing Tables and Columns part of the documentation. Again, code extract from the docu:

    employees = Table(...)
    # or if using declarative
    #employees = Employee.__table__
    
    # or just
    employees.c.employee_id
    
    # via string
    employees.c['employee_id']
    
    # iterate through all columns
    for c in employees.c:
        print c
    
    # access a column's name, type, nullable, primary key, foreign key
    employees.c.employee_id.name
    employees.c.employee_id.type
    employees.c.employee_id.nullable
    employees.c.employee_id.primary_key
    employees.c.employee_dept.foreign_keys
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, In my VS2008 C# editor window I'm trying to get from this: /********
I'm trying to get from an Android Uri to a byte array. I have
I'm trying to get from Line #1 to Line #2 in the below code:
I am trying to get an Audio file through http get from a secure
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I am trying to get coordinates from GPS (this actually gives the values for
I'm trying to get values from nsdata class and doesn't work. here is my
I am trying to get value from passwordbox for developing a simple login functionality,
I'm trying to get information from this site: http://www.gocrimson.com/sports/mbkb/2011-12/roster If you look at that
I'm trying to get content from an RSS2 feed from one of my sites

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.