[sqlalchemy] Re: How to get SA column object from table.col, declarative attribute, or elixir entity attribute

2009-10-07 Thread Randy Syring

Can anyone give me an idea of what I need to do here?  If I can just
get a high level overview of what I need to do, I am happy to read the
documentation and source to fill in the details.

Thanks.

On Oct 1, 1:56 pm, Randy Syring ra...@rcs-comp.com wrote:
 Mike,

 Thank you for the prompt reply:

 On Oct 1, 1:11 pm, Michael Bayer mike...@zzzcomputing.com wrote:

 RandySyring wrote:

  I'm not sure of the context here.  are you generating code or just
  executing SQL ?  

 Ok, maybe a small example.  Here is a declarative object and the how
 the datagrid gets defined:

 http://paste.pocoo.org/show/142448/

 Note that the datagrid currently accepts the column from the table or
 the declarative attribute.  It would also accept an elixir attribute.

 Then, inside the datagrid library, I have references to those objects
 that were passed in.  Use them to construct SQL based on options
 selected by the user.  So, a user might request something like:

 /foo?filteron=firstnamefilteronop=nefilterfor=test*

 and we would generate something like:

 SELECT persons.id AS persons_id, persons.firstname AS
 persons_firstname, persons.last_name AS persons_last_name
 FROM persons
 WHERE persons.firstname NOT LIKE 'test'

 run that against the DB and then return the results in an HTML table.

 The way we generate the SQL is by using the SA/Elixir column/
 attributes in a query, here is a small snippet of that:

 http://paste.pocoo.org/show/142453/

 So, my problem currently is that in the above snippet, ffor might be
 an empty string.  That's fine if the column is a text type, but I have
 to handle it differently if the column is a time stamp.  I am also
 assuming I will run into other problems related to the type of column
 being used that I will need to handle.  But, I can't currently handle
 those situations b/c I don't know enough about the SA objects to
 figure what type they are.

  if the latter wouldn't you be using TypeEngine subclasses
  to handle coersion of type values ?

 And that's where you lose me, sorry.  All I know is that I have an SA
 table column, SA declarative attribute, or elixir entity attribute and
 I need to figure out what type of SA column they represent (i.e.
 DateTime, Time, Date, etc.).  I really have no idea what it will take
 to bridge the gap, hence this post.  :)
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: How to get SA column object from table.col, declarative attribute, or elixir entity attribute

2009-10-01 Thread Michael Bayer

Randy Syring wrote:

 I am trying to write a datagrid library for sqlalchemy which will
 allow easy generation of tables from SA objects.  I would like the
 datagrid to be able to accept a table column, declarative attribute,
 or elixir entity attribute interchangeably.  Since I am building the
 SQL with queries, this has worked well so far, I just use the objects
 and SA takes care of the rest.

 However, I have recently run into a problem that requires the datagrid
 to be a little smarter.  If someone wants to filter on a date, but
 leaves the value as None, then I need to convert the empty string to a
 None.  However, I only want to do that for Date/Time SA columns.

 So, how can I extract the SA column object from a declarative
 attribute or elixir entity?

I'm not sure of the context here.  are you generating code or just
executing SQL ?  if the latter wouldn't you be using TypeEngine subclasses
to handle coersion of type values ?


 Thanks.
 



--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---