SQLAlchemy 0.3.0 Released

7 views
Skip to first unread message

Michael Bayer

unread,
Oct 22, 2006, 3:57:47 PM10/22/06
to sqlal...@googlegroups.com
After a marathon of doc edits and fixes this weekend (and still so
much on the docs is inaccurate...geez..) I've put out the first
release of the 0.3.0 series. Our last release was over 6 weeks ago
which is way too long to be holding back the tons of little bugfixes
that have piled up. At the same time, a lot of internal re-
architecting has gone on, particularly in the ORM, with an emphasis
on clarifcation of concepts, removal of hacky/crufty ways of doing
things, cutting down the tall weeds of things that were written a
year ago, etc. If you've ever wanted to tackle the ORM source code,
this is the best time to do so, as a whole lot of stuff that nobody
could ever understand, including me, has been ripped out and
simplified, made more explicit, had logging added, etc. The
rearchitecting is the main reason i wanted to push onto a new major
version number, since it pushes SA's "maturity" factor one notch up
(i.e. a 3 on a scale of 1 to 10).

Some cool things that were impossible in the last release:

------------------------------------------

Define two tables with a circular foreign key dependency on each
other ! (yes, it uses ALTER TABLE):

t1 = Table('table1', meta,
Column('id', Integer, primary_key=True),
Column('t2_id', Integer, ForeignKey('t2.id'))
)

t2 = Table('table2', meta,
Column('id', Integer, primary_key=True),
Column('t1_id', Integer, ForeignKey('t1.id', use_alter=True,
name='t2id_fk'))
)

meta.create_all()

Notice the "use_alter" flag, which also requires explicitly naming
the foreign key.

------------------------------------------

UniqueConstraint :

t1 = Table('sometable', meta, Column(...), UniqueConstraint('id',
'version'))

------------------------------------------

CheckConstraint:

t1 = Table('sometable', meta, Column('x', Integer), Column('y',
Integer), CheckConstraint('x+y>10'))

------------------------------------------

Fancy Query operations - per-query MapperExtensions, SelectResults
can build joins on the fly:

result = session.query(SomeClass).\
options(extension(SelectResultsExt())).select().\
outerjoin_to('orders').outerjoin_to('items').\
select(or_(Order.c.order_id==None,Item.c.item_id==2)).list()

------------------------------------------

Pessimistic Locking (still needs documentation, spec is in ticket 292):

q = session.query(SomeClass).with_lockmode('update').get(5)

------------------------------------------

Multi-column stored procedures as selectables (with supporting
databases, i.e. postgres and oracle):

myproc = select([
column('x', type=Integer),
column('y', type=Integer),
column('status', type=String),
], from_obj=[func.my_stored_procedure(bindparam('x'),
bindparam('y'), bindparam('z'))],
engine=myengine
)

for row in myproc.execute(x=5,y=7,z=10):
print row['x'], row['y'], row['status']

------------------------------------------

Individual TypeEngines now define the method used by the ORM to
detect changes on an attribute (i.e. like Hibernate does), which
supports "mutable" types such as PickleType:

graphs = Table('graphs', meta, Column('id', Integer,
primary_key=True),
Column('data', PickleType)
)

class Graph(object):pass
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y

mapper(Graph, graphs)

g = Graph()
g.data = [Point(1,2), Point(3,5), Point(10,15)]
session.save(g)
session.flush()
session.clear()

# changes within the contents of "data" are detected, even though no
# "setter" operation occured on "g"
g = session.query(Graph).get_by(id=g.id)
g.data[2] = Point(19,12)
session.flush()

PickleType can be set up with "mutable=False" if you want to prevent
the comparison operation (or make your own PickleType with your own
comparison operation).

------------------------------------------

full CHANGES list, which includes every enhancement and most bugfixes
(minor bugfixes can be viewed on the timeline), can be viewed on the
site:

http://www.sqlalchemy.org/CHANGES


- mike

Jonathan Ellis

unread,
Oct 22, 2006, 11:47:43 PM10/22/06
to sqlal...@googlegroups.com
Looks like another great release!

On 10/22/06, Michael Bayer <zzz...@gmail.com> wrote:
>
> After a marathon of doc edits and fixes this weekend (and still so
> much on the docs is inaccurate...geez..) I've put out the first
> release of the 0.3.0 series.

--
Jonathan Ellis
http://spyced.blogspot.com

Marco Mariani

unread,
Oct 23, 2006, 7:16:56 AM10/23/06
to sqlal...@googlegroups.com
Jonathan Ellis wrote:
> Looks like another great release!
>
Kudos to Michael and anyone involved for bringing forward the only ORM I
feel like using :-)

I like the docs too, but would really appreciate a PDF or PS version
since the layout is not printer-friendly to me. Firefox, Konqueror and
Interne Exploder do not wrap correctly the monospaced text. Openoffice
crashes after filling up my RAM. No need for pagenumber and other frills..

The "one-page" options is also missing from 0.3.


Thanks again

Enrico Morelli

unread,
Oct 23, 2006, 7:58:52 AM10/23/06
to sqlal...@googlegroups.com


I agree with Marco. It's very important to have a printed version
of the documentation. Now is very difficult to print the new
documentation because "one-page" option missing.

Thanks for your wonderful work.

--
-------------------------------------------------------------------
(o_
(o_ //\ Coltivate Linux che tanto Windows si pianta da solo.
(/)_ V_/_
+------------------------------------------------------------------+
| ENRICO MORELLI | email: mor...@CERM.UNIFI.IT |
| * * * * | phone: +39 055 4574269 |
| University of Florence | fax : +39 055 4574253 |
| CERM - via Sacconi, 6 - 50019 Sesto Fiorentino (FI) - ITALY |
+------------------------------------------------------------------+

Julien Cigar

unread,
Oct 23, 2006, 8:15:12 AM10/23/06
to sqlal...@googlegroups.com
thanks for the good work !


--
Julien Cigar
Belgian Biodiversity Platform
http://www.biodiversity.be
Université Libre de Bruxelles
Campus de la Plaine CP 257
Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entrée ULB 2
B-1050 Bruxelles
office: jci...@ulb.ac.be
home: ma...@mordor.ath.cx

Michael Bayer

unread,
Oct 23, 2006, 6:57:39 PM10/23/06
to sqlalchemy
im playing around with the docs to put the "one page" idea back there,
and im noticing the page is so enormous my browser cant navigate the
page anyway (also with the 0.2 docs)...is that what you really want ?

might be nicer if someone wants to work on Markdown->PDF, possibly by
way of LaTeX or something like that (since the content for the docs
exists in markdown format).

Robin Munn

unread,
Oct 24, 2006, 11:07:28 AM10/24/06
to sqlal...@googlegroups.com
On 10/23/06, Michael Bayer <zzz...@gmail.com> wrote:
>
> im playing around with the docs to put the "one page" idea back there,
> and im noticing the page is so enormous my browser cant navigate the
> page anyway (also with the 0.2 docs)...is that what you really want ?
>
> might be nicer if someone wants to work on Markdown->PDF, possibly by
> way of LaTeX or something like that (since the content for the docs
> exists in markdown format).

While you're looking at the doc generation code, you may be interested
to learn about Pygments (http://pygments.pocoo.org/) -- a
general-purpose, extendible syntax highlighter written in Python. You
may not have plans to rewrite the doc/build/lib/highlight.py code
anytime soon -- but if you ever do decide to rewrite it, you'll
probably want to consider existing libraries. And what I've seen of
Pygments so far, I like.

--
Robin Munn
Robin...@gmail.com
GPG key 0xD6497014

Michael Bayer

unread,
Oct 24, 2006, 11:48:31 PM10/24/06
to sqlalchemy

Robin Munn wrote:
> While you're looking at the doc generation code, you may be interested
> to learn about Pygments (http://pygments.pocoo.org/) -- a
> general-purpose, extendible syntax highlighter written in Python. You
> may not have plans to rewrite the doc/build/lib/highlight.py code
> anytime soon -- but if you ever do decide to rewrite it, you'll
> probably want to consider existing libraries. And what I've seen of
> Pygments so far, I like.

had this been around when i wrote the highlighter (like in 2004), i
would most likely have used this (and built the myghty highlighter as
one of its lexers)...it looks really great and just what i was looking
for back then.

Daniel Miller

unread,
Oct 30, 2006, 11:17:11 PM10/30/06
to sqlal...@googlegroups.com
BTW, just wanted to take a moment to say "Thanks!" to all who contribute to SA, and especially to Mike, who is simply amazing! I just upgraded to 0.3 without a hitch. This is by far the most painless upgrade I've had so far. Keep up the good work.

~ Daniel


P.S. Sorry for my apparent absence lately. I've been lurking, but haven't had the time to contribute very much. I'm in the middle of a huge project deployment and don't have much time for anything else.

François Wautier

unread,
Oct 31, 2006, 12:00:01 AM10/31/06
to sqlal...@googlegroups.com

Hi list,

I think I came across a little problem.... I am still using 0.2.8 (+ flush patch), so this may have been solved already...
in which case I apologise

When I do

s=tblRace.select(and_(dbRace.c.id==dbRaceLeg.c.id,dbRaceLeg.c.Date>=bindparam("Race_Date")))
lor=conn.execute((s,Race_Date=datetime.date.today())

I get the expected result...

But when I do

s=tblRace.select(and_(dbRace.c.id==dbRaceLeg.c.id,dbRaceLeg.c.Date>=bindparam("Race_Date"))).compile()
lor=conn.execute((s,Race_Date=datetime.date.today())

I get an exception

File "/usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 246, in execute
return Connection.executors[type(object).__mro__[-2]](self, object, *multiparams, **params)
KeyError: <class 'sqlalchemy.sql.ClauseVisitor'>


Is this a known/solved problem.... or am I doing something wrong?

Cheers,
François

Michael Bayer

unread,
Oct 31, 2006, 9:57:41 AM10/31/06
to sqlalchemy
bug. fixed in 2075.

Reply all
Reply to author
Forward
0 new messages