[sqlalchemy] Re: How to map columns into a tuple using SQLAlchemy?

2009-03-13 Thread Stephen Emslie
You could try changing your _limit tuple to a property on the class that returns the tuple you want. For example: class Result(object): def get_limit(self): return (self.upper, self.lower, self.nominal) _limit = property(get_limit) Is this what you were looking for? Stephen Emslie

[sqlalchemy] getting the number of records in a result set from select

2009-03-13 Thread jeff
hi. this question should be easy. i've searched around though and haven't found the answer. all i want to do is know the number of records in a result set i get using an execute statement with a simple select. so if i do: s=select([raw_table],and_(raw_table.c.name==m

[sqlalchemy] declarative_base with UniqueConstraint

2009-03-13 Thread Chris Lewis
Hi there, I know there's a previous thread, but that's a bit old, so I thought I'd make a new one. The UniqueConstraint for the declarative style doesn't seem to be working for me. Using code from the last thread, I have this: = class Group(Base): __tablename__ = groups

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread Stephen Emslie
Well, I would have expected ResultProxy.rowcount to do just that (return the number of rows in the last executed statement) but I just get 0 from it. Perhaps someone could explain how to use it correctly. Stephen Emslie On Thu, Mar 12, 2009 at 5:20 PM, jeff jeffre...@gmail.com wrote: hi.

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread Michael Bayer
database cursors are essentially iterators so a total rowcount, without fetching all the rows, is not available in a platform-agnostic way. the usual strategy to find out how many rows of something exist in the DB is to do SELECT COUNT(*). Stephen Emslie wrote: Well, I would have expected

[sqlalchemy] Re: declarative_base with UniqueConstraint

2009-03-13 Thread Michael Bayer
UniqueConstraint only represents a constraint being generated along with CREATE TABLE statements, it doesn't affect any in-python behavior. So unless you've created your database using your declarative classes, UniqueConstraint will have no effect. Chris Lewis wrote: Hi there, I know

[sqlalchemy] AttributeError upon postgres_returning

2009-03-13 Thread Gloria W
Hi all, I am trying to use the postgres_returning feature with the latest svn checkout of SqlAlchemy, Python 2.5.2, and Postgresql 8.3. I have a declarative_base, which works in the declarative base context. I get it's table reference this way: al_table =

[sqlalchemy] Re: AttributeError upon postgres_returning

2009-03-13 Thread Michael Bayer
you need to execute() your insert statement. the return value of that is where you can fetchall(). Gloria W wrote: Hi all, I am trying to use the postgres_returning feature with the latest svn checkout of SqlAlchemy, Python 2.5.2, and Postgresql 8.3. I have a declarative_base, which

[sqlalchemy] Re: AttributeError upon postgres_returning

2009-03-13 Thread Gloria W
Argh! I knew it had to be something simple. 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,

[sqlalchemy] Re: How to map columns into a tuple using SQLAlchemy?

2009-03-13 Thread batraone
Hi Stephen, Not exactly what I'm looking for (unless I misunderstand you) as I'd like to not have the individual attributes (lower, nominal, upper) in the class directly and carry just the _limits variable. I have a class Result as follows: class Result: def __init__(self):

[sqlalchemy] Re: Supporting fully-qualified table names and cross-database references in Sybase and SQL Server?

2009-03-13 Thread phrrn...@googlemail.com
opened ticket 1341 for this. http://www.sqlalchemy.org/trac/ticket/1341 --~--~-~--~~~---~--~~ 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

[sqlalchemy] dropping tables that are referenced in foreign key constraints on tables

2009-03-13 Thread phrrn...@googlemail.com
I am encountering a problem with getting the unit tests to run on Sybase because of cascades of errors originating from failure to drop a table that is referenced by a FK constraint in another table. When attempting to drop the people table, I need the SybaseSQLSchemaDropper to emit SQL like

[sqlalchemy] Re: dropping tables that are referenced in foreign key constraints on tables

2009-03-13 Thread Michael Bayer
SQLAlchemy normally drops tables in order of foreign key dependency so that there's no need for ALTER. in the case that two tables have a mutual foreign key dependency, one of the ForeignKey objects has the use_alter=True flag set so that just the one FK gets dropped first via ALTER.

[sqlalchemy] Re: dropping tables that are referenced in foreign key constraints on tables

2009-03-13 Thread phrrn...@googlemail.com
Hi Mike, the situation I am encountering is when the other table is not part of the metadata collection i.e. SQLAlchemy doesn't know anything about it. It looks like the unit-tests enumerate the tables by calling table_names() which causes has_table() and reflecttable() to be called in turn.

[sqlalchemy] Re: dropping tables that are referenced in foreign key constraints on tables

2009-03-13 Thread Michael Bayer
phrrn...@googlemail.com wrote: Hi Mike, the situation I am encountering is when the other table is not part of the metadata collection i.e. SQLAlchemy doesn't know anything about it. It looks like the unit-tests enumerate the tables by calling table_names() which causes has_table() and

[sqlalchemy] Re: dropping tables that are referenced in foreign key constraints on tables

2009-03-13 Thread phrrn...@googlemail.com
Then I must have a bug in the FK introspection. Which unit tests would you suggest getting running first? Is there one that specifically tests foreign key stuff? pjjH On Mar 13, 3:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: phrrn...@googlemail.com wrote: Hi Mike, the situation I

[sqlalchemy] How to best represent a Postgresql table with (1) a composite key, and (2) no sequence

2009-03-13 Thread Gloria W
Hi again, I have this table, which has a composite primary key, and no sequence: # \d log_members Table public.log_members Column | Type | Modifiers +-+--- memberID | integer | not null logentryID | integer | not null Indexes: log_members_pkey

[sqlalchemy] Re: dropping tables that are referenced in foreign key constraints on tables

2009-03-13 Thread Michael Bayer
phrrn...@googlemail.com wrote: Then I must have a bug in the FK introspection. Which unit tests would you suggest getting running first? Is there one that specifically tests foreign key stuff? the tests in engine/reflection.py should do a basic workup of that feature. pjjH On Mar 13,

[sqlalchemy] Re: How to best represent a Postgresql table with (1) a composite key, and (2) no sequence

2009-03-13 Thread Michael Bayer
ignore my previous response to this. The value for your composite primary key columns would originate from the values present in the corresponding row in the activity_log and members tables. If you'd like SQLa to handle that automatically, you'd have to make usage of the relation() function to

[sqlalchemy] getting the record count of records returned in a select

2009-03-13 Thread jeff
hi. this question should be easy. i've searched around though and haven't found the answer. all i want to do is know the number of records in a result set i get using an execute statement with a simple select. so if i do: s=select([raw_table],and_(raw_table.c.name==m

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread jeff
thanks i will use select count (*) i was making a leap that there would be something in pgdb which allows a function like: sql_txt = select * from addresses cursor.execute(sql_txt) rows=cursor.fetchall() rows_returned = cursor_result.rowcount where the rowcount property contains the number of

[sqlalchemy] Re: How to best represent a Postgresql table with (1) a composite key, and (2) no sequence

2009-03-13 Thread Michael Bayer
put autoincrement=False on those columns. Gloria W wrote: Hi again, I have this table, which has a composite primary key, and no sequence: # \d log_members Table public.log_members Column | Type | Modifiers +-+--- memberID | integer | not null

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread Mike Conley
If you use rows = cursor.fetchall() you have already executed the query and the result is a list of RowProxy's returned by the query. Count then is simply count = len(rows) Otherwise, the count(*) approach is correct. -- Mike Conley On Fri, Mar 13, 2009 at 4:42 PM, jeff

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread jeff
thank you that got me where i was trying to get. originally in the first example i was not adding the fetchall(). len() and rowcount were not yielding anything in that case. then once fetchall() was added i used len() as suggested and it worked. thanks. On Mar 13, 9:30 pm, Mike Conley

[sqlalchemy] [OT] new to macos any db viewer you recommend?

2009-03-13 Thread Jorge Vargas
Hello, Will anyone recommend me a nice tool to view/analyze my databases? I normally use the shell and SA but I'm starting a project with an existing db (and heavy on db procedures and trigger) so I'll like to have some sort of GUI to simplify my learning curve. After some searching I found

[sqlalchemy] Re: How to best represent a Postgresql table with (1) a composite key, and (2) no sequence

2009-03-13 Thread Gloria W
Excellent, thank you. I won't get to try this until Monday. Gloria --~--~-~--~~~---~--~~ 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