I don't know what the design decisions were regarding the Sequence
object, so bear with my ignorance for a moment here.

I played with SQLAlchemy in conjunction with Pylons. I had code that
looked like this:

  links_table = Table('links', metadata,
    Column('id', types.Numeric(), schema.Sequence('link_id_seq'),
primary_key=True),
    Column('title', types.Unicode(), ),
    Column('url', types.Unicode(), )
  )

Of course, using SQLite, this leads to missing 'id' when inserting a
new row since, as far as I can tell, SQLite doesn't support sequences.

The interesting part is the following. If I take the sequence out and
treat it as something separate:

  id_seq = schema.Sequence('id_seq', 1000)

And then leave it out of the table defined above, then I can do
something like this:

    log.info("Adding test link...")
    link = model.Link()
    link.id = engine.execute(model.id_seq)
    log.info("link.id = %r" % link.id)

Well, except for the bit about the link.id being None in SQLite.

The following questions are more about design than implementation.
That is, there may be something about the assumptions SQLAlchemy makes
and how it handles different things.

Shouldn't SQLAlchemy throw an exception when you try to grab the next
value of a non-existant sequence?

Should SQLAlchemy implement a crude version of sequences in Python to
cover up deficient SQL implemetnations? I imagine it is technically
possible. We can have a table that stores the last value of the
sequence and its parameters, and then in those databases just go look
up the last state of the sequence there. But is this in the spirit of
the SQLAlchemy design?

Should sequences be sequences first-class citizens of the schema like
tables are? That is, why do I have to create them and drop them
separately? Why can't we have a "next()" method for sequences and then
bind sequences to the metadata the same way tables are?

If you are looking for development help, I have some spare time here
and there and this is actually interesting. If someone can point the
way to go, I can take it from there.

Otherwise, I am incredibly surprised at how well SQLAlchemy works in
allowing me to write truly database independent applications. You have
done something I don't think anyone else has ever done in the history
of computing, and for that you should be proud.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to