[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 t

[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).gr

[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 rec

[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 aggre

[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 > > S

[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.postgr

[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 sqlalch

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

2007-09-23 Thread voltron
l it. im > 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 i

[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 sub

[sqlalchemy] Re: Self referencing keys

2007-09-03 Thread voltron
ot;, String(255),unique=True, nullable=False), Column("firstname", String(255)), Column("lastname", String(255)), Column("modifiedby_id", Integer, ForeignKey("users.id")) Column("modifiedon",DateTime(timez

[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 recei

[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)

[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 ar

[sqlalchemy] TEXT Column type

2007-08-30 Thread voltron
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 to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubs

[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. > >

[sqlalchemy] Column type -->Timestamp with timezone?

2007-07-02 Thread voltron
How does one declare Timestamp fields with timezones? The DateTime maps to TimeStamp without. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalche

[sqlalchemy] drop_all(). with cascade?

2007-06-29 Thread voltron
Sorry if this sis obvious, can one cascade database dropping when using metadata.drop_all()? thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchem

[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] 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

[sqlalchemy] Re: BETWEEN in where clause?

2007-06-28 Thread voltron
Jun 28, 11:41 pm, [EMAIL PROTECTED] wrote: > between is a method of 2 args, min and max: > table.c.between(x,y), in your case: > select( links.c.lft.between(3,10) ) > > On Thursday 28 June 2007 23:55:26 voltron wrote: > > > This does not work either :-( > > > result

[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 em

[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: Group by? Still a problem

2007-06-27 Thread voltron
e\base.py 602 > > "SQLError: (ProgrammingError) column ""user.id"" must appear in the > > GROUP BY clause or be used in an aggregate function > > > On Jun 27, 9:09 pm, Andreas Jung <[EMAIL PROTECTED]> wrote: > > >> --On 27. Juni 2007 1

[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_

[sqlalchemy] Re: Group by? Still a problem

2007-06-27 Thread voltron
:07 pm, 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 &l

[sqlalchemy] Re: Group by?

2007-06-27 Thread voltron
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 t

[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 unsub

[sqlalchemy] Re: Table updates using data mapping

2007-06-26 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

[sqlalchemy] Re: Table updates using data mapping

2007-06-26 Thread voltron
objects, and then issue a session > flush(). > > This type of > bulk operation is best done with the SQL generation portion of the library, > like so (using an implicit bound connection here): > >users.update(users.c.group == contractor).execute({users.c.group = > consu

[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

[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 be

[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 yo

[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 b

[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 the

[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] 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: 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 shou

[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 myapp.lib.b

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
current_obj(), attr, value) File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste \registry.py", li ne 177, in _current_obj raise TypeError( TypeError: No object (name: G) has been registered for this thread On Jun 13, 6:15 pm, Michael Bayer <[EMAIL PROTEC

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
s case? thanks On Jun 13, 3:11 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Jun 13, 2007, at 7:54 AM, voltron wrote: > > > > > 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 >

[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 attr

[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 da

[sqlalchemy] Re: Problems with non existing relations

2007-06-12 Thread voltron
NCES rol es (id)\n)\n\n' {} D:\Projects\Pylons_projects\gameolymp> On Jun 12, 3:50 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > its very possible that if you just posted a complete stack trace, the > issue may be apparent. > > On Jun 12, 4:39 am, voltron <[EMAIL PROTECTED

[sqlalchemy] Problems with non existing relations

2007-06-12 Thread voltron
I have a set ob tables, access objects and mappers defined, on trying to setup my pylons app, which ultimately calls table.create() I get a " relation does not exist " error, but I know the relation exists in the mapper that I defined. Several other tables are created without problems Is there so