Simple example

Create a file, called, and include the following:

''' Trivial Eve-SQLAlchemy example. '''
from eve import Eve
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import column_property

from eve_sqlalchemy import SQL
from eve_sqlalchemy.config import DomainConfig, ResourceConfig
from eve_sqlalchemy.validation import ValidatorSQL

Base = declarative_base()

class People(Base):
    __tablename__ = 'people'
    id = Column(Integer, primary_key=True, autoincrement=True)
    firstname = Column(String(80))
    lastname = Column(String(120))
    fullname = column_property(firstname + " " + lastname)

    'DEBUG': True,
    'SQLALCHEMY_DATABASE_URI': 'sqlite://',
    'DOMAIN': DomainConfig({
        'people': ResourceConfig(People)

app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL)

# bind SQLAlchemy
db =
Base.metadata.bind = db.engine
db.Model = Base

# Insert some example data in the db
if not db.session.query(People).count():
        People(firstname=u'George', lastname=u'Washington'),
        People(firstname=u'John', lastname=u'Adams'),
        People(firstname=u'Thomas', lastname=u'Jefferson')])

# using reloader will destroy in-memory sqlite db, use_reloader=False)

Run this command to start the server:


Open the following in your browser to confirm that the server is serving:

You will see something like this:

    <link rel="child" href="people" title="people"/>

Now try the people URL:

You will see the three records we preloaded.

<resource href="people" title="people">
    <link rel="parent" href="/" title="home"/>
    <_updated>Sun, 22 Feb 2015 16:28:00 GMT</_updated>
    <fullname>George Washington</fullname>