[sqlalchemy] Implementing ranking

2007-12-19 Thread voltron
Could someone tell me how to simulate the rank() function? I am using PostgreSQL which does not have this a s a native function. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

[sqlalchemy] Group_by 0.4 sytax

2007-12-18 Thread voltron
I am trying to retrieve unique users from a table using this: results = sa_session.query(TempScore).group_by(TempScore.user_name) This unfortunately causes the error below: There was a problem: (ProgrammingError) column temp_scores.id must appear in the GROUP BY clause or be used in an

[sqlalchemy] Querying and retrieving the position of a result

2007-12-18 Thread voltron
I have numerical values assigned to user in a table, I have query the table, sort the table in a descending order and then return the value of a certain user with his position/rank in the table.Could someone give me a leg up? Thanks --~--~-~--~~~---~--~~ You

[sqlalchemy] Re: Group_by 0.4 sytax

2007-12-18 Thread voltron
Thanks! I'll try that out Mike On Dec 18, 3:55 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Dec 18, 2007, at 9:49 AM, voltron wrote: I am trying to retrieve unique users from a table using this: results = sa_session.query(TempScore).group_by(TempScore.user_name) This unfortunately

[sqlalchemy] Re: ANNOUNCE: Spiff Guard 1.9.0

2007-12-03 Thread voltron
Hi! import Guard, as in the tutorial does not work. Any ideas? Easy:installing was problematic, but installing( and python setup.py install) from the download worked. I' m using windows python 2.4 Thanks! On Dec 2, 11:07 pm, Samuel [EMAIL PROTECTED] wrote: Introduction Spiff

[sqlalchemy] Mapping serial(auto increment) Postgres to bigserial

2007-10-02 Thread voltron
How does one specify that the auto incrementing field should map to big serial and not serial? thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: Mapping serial(auto increment) Postgres to bigserial

2007-10-02 Thread voltron
Thanks On Oct 2, 3:54 pm, Ants Aasma [EMAIL PROTECTED] wrote: On Oct 2, 10:06 am, voltron [EMAIL PROTECTED] wrote: How does one specify that the auto incrementing field should map to big serial and not serial? Use the sqlalchemy.databases.postgres.PGBigInteger datatype for that field

[sqlalchemy] Backport for 0.4 on Python 2.4?

2007-09-23 Thread voltron
I have to use PGArray fields, but I think this is only available using SQlalchemy 0.4. Easy_install only installs 0.4 when it detects Python 2.5. Is there some sort of backport available? Thanks --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: Backport for 0.4 on Python 2.4?

2007-09-23 Thread voltron
not sure what easy_install issue youre having (i only run py 2.4 here). On Sep 23, 2007, at 4:59 PM, voltron wrote: I have to use PGArray fields, but I think this is only available using SQlalchemy 0.4. Easy_install only installs 0.4 when it detects Python 2.5. Is there some sort of backport

[sqlalchemy] Self referencing keys

2007-09-03 Thread voltron
Excuse the newbie question, how does one declare a sef-referencing key? I would like to have fields modified_by and created_by in my users table, the field should refer back to the user id or user name in the same table. Thanks --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: Self referencing keys

2007-09-03 Thread voltron
), Column(firstname, String(255)), Column(lastname, String(255)), Column(modifiedby_id, Integer, ForeignKey(users.id)) Column(modifiedon,DateTime(timezone=True), default=func.now()), On Sep 3, 6:50 pm, voltron [EMAIL PROTECTED] wrote: Excuse the newbie question, how does

[sqlalchemy] Re: TEXT Column type

2007-08-30 Thread voltron
is this correct? import sqlalchemy.types as types On Aug 30, 10:07 pm, voltron [EMAIL PROTECTED] wrote: Hi all What do I have to import to be able to use the column type TEXT? --~--~-~--~~~---~--~~ You received this message because you are subscribed

[sqlalchemy] Re: TEXT Column type

2007-08-30 Thread voltron
Thanks! On Aug 30, 10:13 pm, jason kirtland [EMAIL PROTECTED] wrote: voltron wrote: Hi all What do I have to import to be able to use the column type TEXT? from sqlalchemy import Column, TEXT Column('mytext', TEXT) or use 'String' without a length qualifier: from sqlalchemy

[sqlalchemy] Re: Column type --Timestamp with timezone?

2007-07-02 Thread voltron
Thanks! On Jul 2, 10:14 pm, Benjamin Smedberg [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 voltron wrote: How does one declare Timestamp fields with timezones? The DateTime maps to TimeStamp without. DateTime(timezone=True) - --BDS - -- Benjamin Smedberg

[sqlalchemy] Re: BETWEEN in where clause?

2007-06-29 Thread voltron
aha, this works resultset = select([links] , links.c.lft.between(5,17), order_by=links.c.lft).execute() On Jun 29, 12:00 am, voltron [EMAIL PROTECTED] wrote: Thanks for your reply,now I dont have errors, but the results are unexpected, I have a list of booleans if I iterate through the result

[sqlalchemy] SAContext and transactions?

2007-06-29 Thread voltron
I´m not sure if I should ask this here or the Pylons forum: How does one wrap a query in a transaction when using SAContext? Could someone post some example code? Also, I read somewhere that SQL92 defined transactions eliminate the need to lock tables, is that right? Thanks

[sqlalchemy] BETWEEN in where clause?

2007-06-28 Thread voltron
How would would write a query with a BETWEEN? This does not produce what I want resultset = select([links, links.c.lft 3, links.c.lft 10]).execute() I would like all the values lft in table links greater than 3 but less than 10 I am using PostgreSQL Thanks

[sqlalchemy] Re: BETWEEN in where clause?

2007-06-28 Thread voltron
This does not work either :-( resultset = select([links.c.lft.between(links.c.lft 3,links.c.lft 10) ]).execute() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email

[sqlalchemy] Re: Table updates using data mapping

2007-06-27 Thread voltron
Thanks Mike, that clears up a few things On Jun 27, 2:08 am, Mike Orr [EMAIL PROTECTED] wrote: On 6/26/07, voltron [EMAIL PROTECTED] wrote: sess = create_session() allusers = sess.query(User).select() for user in allusers: user.group = contractor print x.name This adds

[sqlalchemy] Group by?

2007-06-27 Thread voltron
How can I construct the clause group by using SQL construction? 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

[sqlalchemy] Re: Group by? Still a problem

2007-06-27 Thread voltron
, voltron [EMAIL PROTECTED] wrote: Thanks. I did not find this in the docs. http://www.sqlalchemy.org/docs/sqlconstruction.html On Jun 27, 4:01 pm, Andreas Jung [EMAIL PROTECTED] wrote: --On 27. Juni 2007 06:47:37 -0700 voltron [EMAIL PROTECTED] wrote: How can I construct the clause group

[sqlalchemy] Re: Group by? Still a problem

2007-06-27 Thread voltron
. Juni 2007 12:00:13 -0700 voltron [EMAIL PROTECTED] wrote: I´m guessing a bit because I still could not find the group_by entry in the docs This works: user.select(links.c.id 3, order_by=[user.c.id]).execute() but this does not user.select(links.c.id 3,group_by=[user.c.dept

[sqlalchemy] Re: Group by? Still a problem

2007-06-27 Thread voltron
[EMAIL PROTECTED] wrote: --On 27. Juni 2007 12:00:13 -0700 voltron [EMAIL PROTECTED] wrote: I´m guessing a bit because I still could not find the group_by entry in the docs This works: user.select(links.c.id 3, order_by=[user.c.id]).execute() but this does not user.select

[sqlalchemy] Re: Storing JSON objects, maybe OT

2007-06-26 Thread voltron
Thanks Arnar! I´ll prefer to take this off the list since it is only slightly related to SQLAlchemy. On Jun 26, 2:28 am, Arnar Birgisson [EMAIL PROTECTED] wrote: On 6/25/07, voltron [EMAIL PROTECTED] wrote: Thank you very much for your feedback guys! I was very worried the whole day. I

[sqlalchemy] Table updates using data mapping

2007-06-26 Thread voltron
Could someone tell me how I would execute this SQL using data mapping? # SQL UPDATE users SET group=consultant WHERE group = contractor; # Mapped object user_mapper = mapper(User, users) user = User() Thanks --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: Table updates using data mapping

2007-06-26 Thread voltron
would I have to do something like this? sess = create_session() allusers = sess.query(User).select() for user in allusers: user.group = contractor print x.name On Jun 26, 10:40 pm, voltron [EMAIL PROTECTED] wrote: Could someone tell me how I would execute this SQL using data mapping

[sqlalchemy] Storing JSON objects, maybe OT

2007-06-25 Thread voltron
I apologize if this is the wrong place to ask this question. I would like to store and retrieve JSON objects from a database, the JSON object holds a list of menu items for my site. What would be the best way to achieve this? 1. Convert the JSON object to Python code using simplejson, pickle

[sqlalchemy] Re: Storing JSON objects, maybe OT

2007-06-25 Thread voltron
Thank you very much for your feedback guys! I was very worried the whole day. I did some research and found this: http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/index.html This shows different methods of storing hierarchical data, but I just did not like the mind

[sqlalchemy] Sequences

2007-06-15 Thread voltron
Could someone point me to the documentation about declaring and using Sequence fields in Sqlalchemy? If there are no docs, could someone give a rundown? I can imagine how it could be used, but I´ll be working in the dark without documentation. Thanks

[sqlalchemy] flushing and saving data using default_metadata

2007-06-13 Thread voltron
I have decided to use the global_metada to setup the tables in my app, in one of the tables, users, I setup an admin account user = User(john doe, [EMAIL PROTECTED]) how do I flush the the above object? user.flush() does not work in this context because the User object does not have the

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
(name: G) has been registered for this thread On Jun 13, 6:15 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jun 13, 2007, at 12:07 PM, voltron wrote: aha, ok, thanks, but I saw it in the docs, ist it deprecated? Then I ´m in a spot DynamicMetaData is not deprecated. but when you

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
almost there: I put this in base.py from sqlalchemy import * metadata = MetaData() so anywhere I need it I just import: from gameolymp.lib.base import * I have no errors, but no databases are created or dropped, this is what I added to my websetup.py from sqlalchemy import * from

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
I have found a solution which works, but what is the correct way Michael? I created in base.py: metadata = DynamicMetaData() then in my websetup.py : uri = conf['sqlalchemy.dburi'] engine = create_engine(uri) metadata.connect(uri) metadata.create_all() this works, but you mentioned that I

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
another thing, g does not work from websetup.py, which I would have liked 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

[sqlalchemy] Re: Problems with non existing relations

2007-06-12 Thread voltron
actually, I am iterating through all the databases in the meta ti = model.meta.table_iterator() for t in ti: print create %s ? % t if raw_input(Choose [Y/n]).lower() in ['y','']: t.create() I want to be able to chose which database to create from a pool on