[sqlalchemy] Checking if a table already has data in it.

2009-10-26 Thread todd12

Hello all,

Is there a better way to check if a table has data in it, instead of
doing a query and fetching one item?

Thanks,

t
--~--~-~--~~~---~--~~
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] getting data from primary keys

2009-09-14 Thread todd12

Hello SQLAlchemy Group,

I've been trying to work out a way I can get the data from a table
whose columns are primary keys.

The challenge is, I don't know before hand which columns are primary
keys since the code is to be run on different tables.

I've figured out how to get the primary keys from a table object:

cols = table.columns

primary_col_names = []
for col in cols:
if col.primary_key is True:
primary_col_names.append(col.column_name)

But how do I go about constructing an sql statement with the primary
column names in the list?

Or is there an easier way to do this?

I've found away to do this using where(), feeding it the column_name,
but if there were three names in the primary_col_names list I'd have
to append a where for each name, and I'm not entirely sure how that
would work.

Is there a way to give SQLAlchemy a string sql statement?

Cheers,

T

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---