Errata

Essential SQLAlchemy

Errata for Essential SQLAlchemy

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page viii
Under "Contents of This Book", "Chapter 2, Getting Started" Second sentence.

"though" should be "through"

Anonymous  Mar 28, 2011 
3.2.1
1st code section

The third example of bound Metadata should be:

# Create an engine and then a bound MetaData
db2 = create_engine('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

instead of:

# Create an engine and then a bound MetaData
db2 = MetaData('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

Anonymous  Jun 23, 2008 
Printed
Page 6
Top of page

First python example should be as follows ('admin' should be permission_name):

def user_has_permission(user, permission_name):
for g in user.groups:
for p in g.permissions:
if p.permission_name == permission_name:
return True
return False


instead of:

def user_has_permission(user, permission_name):
for g in user.groups:
for p in g.permissions:
if p.permission_name == 'admin':
return True
return False

Anonymous  May 09, 2011 
PDF
Page 10
1st paragraph

Written "freshly fetched from the databaES"
should be "databaSE"

Vladimir  Jun 18, 2012 
PDF
Page 11
3rd paragraph of 'Connection Pooling' section

"If you would like to manually manage your connections..."

instead of

"If you would like to manually manage your collections..."

Anonymous  Dec 05, 2011 
Printed
Page 12
The third MetaData example in the third code example.

The third MetaData example should be:

# Create an engine and then a bound MetaData
db2 = create_engine('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

instead of:

# Create an engine and then a bound MetaData
db2 = MetaData('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

Anonymous   
PDF
Page 29
Snippet of code before last 2 paragraphs

This seems to be a version change issue, but I thought it significant enough to be mentioned. I'm using SQLAlchemy version 0.7.2 and apparently, on that version the snippet

>>> for user in query.filter(User.c.user_name.like('rick%')):

should be changed to

>>> for user in query.filter(User.user_name.like('rick%')):

Note from the Author or Editor:
This should probably be put in a "Version 0.7" sidebar.

Anonymous  Dec 06, 2011 
PDF
Page 30
top of the page

There have been some changes with the API of Session in SQLAlchemy version 0.7.2

To add an object to the session one uses the add() method, rather than save(). Therefore, the snippet at the top should be

>>> newuser.password = 'password'
>>> session.add(newuser)

instead of

>>> newuser.password = 'password'
>>> session.save(newuser)

Note from the Author or Editor:
This should probably be put in a "Version 0.7" sidebar.

Anonymous  Dec 06, 2011 
Printed
Page 39
First code example

The first database instance is created as "db1" but it is latter referred to as "db". That is, one should read:
db1 = create_engine('sqlite://')
unbound_meta.bind = db1
instead of
db1 = create_engine('sqlite://')
unbound_meta.bind = db

Yannick Gingras  Dec 07, 2008 
Printed
Page 39
1st code section

The third example of bound Metadata should be:

# Create an engine and then a bound MetaData
db2 = create_engine('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

instead of:

# Create an engine and then a bound MetaData
db2 = MetaData('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

Anonymous   
PDF
Page 49
First example of Active defaults

The parentheses count is inaccurate. There should only be 2 parentheses when closing the Table and the Column before the last should also have 2 closing parens.

This

user_table = Table(
'tf_user', MetaData(),
Column('id', Integer, primary_key=True),
Column('user_name', Unicode(16), unique=True, nullable=False),
Column('password', Unicode(40), nullable=False),
Column('first_name', Unicode(255), default=''),
Column('last_name', Unicode(255), default=''),
Column('created_apptime', DateTime, default=datetime.now),
Column('created_dbtime', DateTime,
default=func.current_timestamp(),
Column('modified', DateTime, onupdate=datetime.now)))

should be this

user_table = Table(
'tf_user', MetaData(),
Column('id', Integer, primary_key=True),
Column('user_name', Unicode(16), unique=True, nullable=False),
Column('password', Unicode(40), nullable=False),
Column('first_name', Unicode(255), default=''),
Column('last_name', Unicode(255), default=''),
Column('created_apptime', DateTime, default=datetime.now),
Column('created_dbtime', DateTime,
default=func.current_timestamp()),
Column('modified', DateTime, onupdate=datetime.now))

Anonymous  Dec 14, 2011 
Printed
Page 55
1st code section

The second Metadata creation example should be:

# Create an engine and then a bound MetaData
db2 = create_engine('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

instead of:

# Create an engine and then a bound MetaData
db2 = MetaData('sqlite:///test1.db')
bound_meta1 = MetaData(db2)

Anonymous   
Printed
Page 56
2nd paragraph after "Create/drop MetaData and schema objects", last argument on page

The default for checkfirst in create_all()/drop_all() is True, not False. This is stated in the online-documentation of SQLAlchemy as well as in the book on page 26 last paragraph before "Perfoming Queries and Updates"

Anonymous  Dec 28, 2008