when you say:

table.select()

that returns to you an unexecuted selectable object.  to get a result, execute it:

result = table.select().execute()

just like the docs say for SQL constrcution.

the example youre referencing below refers to mappers, not tables, which are a different concept altogether.

there is a "tutorial" document under construction which will perhaps clarify alot of these issues without needing to read the entire SA documentation, but for now, well, reading the entire SA documentation would help ;)
 


On Apr 1, 2006, at 10:44 AM, Jonathan Hayward http://JonathansCorner.com wrote:

I am trying to figure out how to ask for the nth result in a result set. I have a method that ends:

        return document_table.select(where, \
          order_by=[sqlalchemy.desc(document_table.columns.last_viewed)])

How do I obtain either results one at a time, like an SQL cursor (looping through "Give me the first result I haven't seen")? The impression I got from the documentation was that there was an array-like syntax*, but Python was not responding positively to my treating it as an array:

Traceback (most recent call last):
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 5807, in ?
    multitasking.start_oracle()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 3474, in start_oracle
    self.run_oracle()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 3435, in run_oracle
    self.handle_oracle_query(newsocket, address)
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 3382, in handle_oracle_query
    generate_output()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 5122, in generate_output
    current_frame.display()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 2776, in display
    build_output_for_appropriate_search_results()
  File "/server1/users/jonathan/creations/inventions/software/insight/alchemy", line 4635, in build_output_for_appropriate_search_results
    current_result = search_results[index]
TypeError: unindexable object

* I was looking at, in the docs, the example for the Basic Data Mapping synopsis:

# class definition 
class User(object ):
pass

# create a mapper
usermapper = mapper( User, users)

# select
sqluser = usermapper .select_by(user_name='fred' )[0]
# modify
user.user_name = 'fred jones'

# commit - saves everything that changed
sqlobjectstore.commit()

--
++ Jonathan Hayward, [EMAIL PROTECTED]
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail (gmail.com) account, please tell me!

Reply via email to