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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:17:49+00:00 2026-05-31T23:17:49+00:00

The docs for Camelot say that it uses Elixir models. Since SQLAlchemy has included

  • 0

The docs for Camelot say that it uses Elixir models. Since SQLAlchemy has included declarative_base for a while, I had used that instead of Elixir for another app. Now I would like to use the SQLAlchemy/declarative models directly in Camelot.

There is a post on Stackoverflow that says Camelot is not tied to Elixir and that using different models would be possible but it doesn’t say how.

Camelot’s original model.py only has this content:

import camelot.types
from camelot.model import metadata, Entity, Field, ManyToOne, OneToMany, Unicode, Date, Integer, using_options
from camelot.view.elixir_admin import EntityAdmin
from camelot.view.forms import *

__metadata__ = metadata

I added my SQLAlchemy model and changed model.py to this:

import camelot.types
from camelot.model import metadata, Entity, Field, ManyToOne, OneToMany, Unicode, Date, using_options
from camelot.view.elixir_admin import EntityAdmin
from camelot.view.forms import *

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

Base = declarative_base()

__metadata__ = metadata
Base = declarative_base()

class Test(Base):
    __tablename__ = "test"
    id = Column(Integer, primary_key=True)
    text = Column(String)

It didn’t work. When I start main.py, I can see the GUI and Test in the sidebar, but can’t see any rows. This is the tail of the traceback:

File "/usr/lib/python2.6/dist-packages/camelot/view/elixir_admin.py", line 52, in get_query
    return self.entity.query
AttributeError: type object 'Test' has no attribute 'query'

This is the elixir_admin.py code for line 46-52:

@model_function
def get_query(self):
    """:return: an sqlalchemy query for all the objects that should be
    displayed in the table or the selection view.  Overwrite this method to
    change the default query, which selects all rows in the database.
    """
    return self.entity.query

If this code is causing the problem, how do I overwrite the method to change the default query to make it work?

How can you use SQLAlchemy/declarative models in Camelot?

  • 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-05-31T23:17:51+00:00Added an answer on May 31, 2026 at 11:17 pm

    Here is some sample code on using Declarative to define a Movie model for Camelot, some explanation can be found here.

    import sqlalchemy.types
    from sqlalchemy import Column
    from sqlalchemy.ext.declarative import ( declarative_base, 
                                             _declarative_constructor )
    
    from camelot.admin.entity_admin import EntityAdmin
    from camelot.model import metadata
    import camelot.types
    
    from elixir import session
    
    class Entity( object ):
    
        def __init__( self, **kwargs ):
            _declarative_constructor( self, **kwargs )
            session.add( self )
    
    Entity = declarative_base( cls = Entity, 
                               metadata = metadata,
                               constructor = None )
    
    class Movie( Entity ):
    
        __tablename__ = 'movie'
    
        id = Column( sqlalchemy.types.Integer, primary_key = True )
        name = Column( sqlalchemy.types.Unicode(50), nullable = False )
        cover = Column( camelot.types.Image(), nullable = True )
    
        class Admin( EntityAdmin ):
            list_display = ['name']
            form_display = ['name', 'cover']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MSDN docs say that only value types need boxing, but this does not apply
The docs about openssl_sign() say that the signature is returned in the passed string
The docs say that I should not release any modeled property in -dealloc. For
The docs vaguely say that it will stick around as long as needed, but
MySQL docs say that tables that use the MERGE storage engine can only union
Django docs say that Context object is a stack: from django.template import Context c
The docs say that calling CTTypesetterCreateLine is the same as calling CTTypesetterCreateLineWithOffset with offset
Python docs states that uuid1 uses current time to form the uuid value. But
SQLite docs specifies that the preferred format for storing datetime values in the DB
The docs of Java 7 for FileWriter and FileOutputStream shows that the constructor of

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.