Re: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread Daniel Miller
First, let me state that engine.begin/commit has always confused the heck out of me so I just acted like it didn't exist. Why do we need it? If transactions are needed at the connection level, then use the connection.begin/commit for that (maybe connection.begin() should return a SQLTransaction

Re: [Sqlalchemy-users] Insert and obliterate

2006-04-03 Thread Daniel Miller
Jonathan Hayward http://JonathansCorner.com wrote: Is there a way to specify an insert that says "Overwrite any previous rows containing this row's primary key"? In SQL that's two queries: delete from users where user_id = ? insert into users (user_id, ...) values (?, ...) SQLAlchemy can

Re: [Sqlalchemy-users] Support for CAST

2006-04-03 Thread Robert Leftwich
Michael Bayer wrote: ok well how should it look ? do you want to take a crack at it? Done as at r1256. It leverage's off of the existing sqlalchemy.types for some degree of database independence, e.g. select([cast(tbl.c.integer_col as TEXT)]) will end up as SELECT CAST(table_nam

Re: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread HD Mail
Michael, This thread is making me think that I am using transactions in SA incorrectly. I use a transaction decorator like below def transaction(func): def trans_func(*args, **kws): log.warn('* TRANS BEGIN ***') engine.begin() try: f = func(*args, **k

Re[8]: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread Gambit
So from what you said below: trans = engine.begin() # do some explicit SQL trans.commit() # Commits all the explicit SQL, as we'd expect objectstore.push_session(objectstore.Session(import_imap=True)) trans = session.begin_transaction() foo = Foo() bar = Bar() # other UOW behavio

Re: Re[6]: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread Michael Bayer
gambit - the various push-based interfaces have some room for streamlining. but the more immediate issue is that everyone is confusing engine.begin()/commit() with objectstore.begin()/commit(), as youve done below. I am beginning to think a somewhat radical API change might be the only w

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Rick Morrison
Yep, here's one for MS-SQL 2000: http://www.microsoft.com/downloads/details.aspx?FamilyID=413744d1-a0bc-479f-bafa-e4b278eb9147&DisplayLang=en There's one for the new version as well (http://www.microsoft.com/sql/editions/express/default.mspx), but I wouldn't think that it's widely deployed yet,

Re[6]: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread Gambit
Hey Michael, Just looking at your usage there, but would it make any sense at all to have engine.begin() and engine.push_session() turn into one method? Does it make sense to create multiple sessions if you're not going to be doing simultaneous transactions? I think I'm looking for a way to some

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Michael Bayer
is there a free developer version of MS-SQL out  there ?  runs on XP perhaps ?On Apr 3, 2006, at 6:36 PM, Rick Morrison wrote:Sure, for example, previous version failed the DateTest in testtypes.py; issuing the SELECT with no FROM clause. Thanks for rolling it in. Rick On 4/3/06, Michael Bayer <[

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Rick Morrison
Sure, for example, previous version failed the DateTest in testtypes.py; issuing the SELECT with no FROM clause. Thanks for rolling it in. Rick On 4/3/06, Michael Bayer <[EMAIL PROTECTED]> wrote: Rick -it passes the same unit tests I was using, so if it works for other cases I didnt try (since I

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Michael Bayer
Rick -it passes the same unit tests I was using, so if it works for other cases I didnt try (since I hardly tried any), great (can you produce a unit test that fails with the previous version? not so crucial tho).  committed in rev 1254.- mikeOn Apr 3, 2006, at 5:12 PM, Rick Morrison wrote:Didn't w

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Rick Morrison
Didn't work for me, Mike -- didn't generate FROM clauses at all for normal non-aliased, same-schema SELECT queries.  Did you maybe mean this way? (clean patch also attached). def visit_table(self, table): # alias schema-qualified tables - if self.tablealiases.has_key(table):

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Michael Bayer
OH...um, why yes it is ! as of 15 seconds ago. enjoy ! On Apr 3, 2006, at 5:40 AM, Michael Twomey wrote: On 4/3/06, Michael Bayer <[EMAIL PROTECTED]> wrote: i committed the whole thing with a working version of the Alias thing i Hi Rick and Michael, Thanks for adding mssql support, I've

Re: Re[4]: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread Michael Bayer
Yah, ok , youre getting into features that were just written a few weeks ago, if you want simultaneous transactions, theres a feature on engine called "push_session"/"pop_session". you should not be creating multiple engines for the same connection (i mean, you can, but the experience will

Re: [Sqlalchemy-users] ...SORT BY score DESC...

2006-04-03 Thread Qvx
You cannot select "table", you must select tabe columns like "doc.c1, doc.c2" or "doc.*", but then you must expand your group by clause. Also it seems to me that you have connected you "doc" and "his" tables in an sub-optimal way. It should have been an integer column and not varchar column that co

Re: [Sqlalchemy-users] ...SORT BY score DESC...

2006-04-03 Thread Jonathan Hayward http://JonathansCorner.com
On 4/3/06, Qvx <[EMAIL PROTECTED]> wrote: Stored procedure will be different for each database. I can help you with Oracle.I would make my query like this:SELECT doc.id, SUM( his.cnt/doc.word_count) weight  FROM doc, his WHERE doc.id = his.doc_id   AND his.word IN (:w1, :w2, :w3)  GROUP BY doc.idH

Re: [Sqlalchemy-users] ...SORT BY score DESC...

2006-04-03 Thread Jonathan Ellis
Postgresql supports user-defined aggregate functions.  You don't need them very often, but it's handy when you do. :)On 4/3/06, Qvx < [EMAIL PROTECTED]> wrote:Stored procedure will be different for each database. I can help you with Oracle. I would make my query like this:SELECT doc.id, SUM( his.cn

Re: [Sqlalchemy-users] ...SORT BY score DESC...

2006-04-03 Thread Qvx
Stored procedure will be different for each database. I can help you with Oracle.I would make my query like this:SELECT doc.id, SUM( his.cnt/doc.word_count) weight  FROM doc, his WHERE doc.id = his.doc_id   AND his.word IN (:w1, :w2, :w3) GROUP BY doc.idHAVING COUNT(*) = :num_search_words  ORDER BY

Re: [Sqlalchemy-users] ...SORT BY score DESC...

2006-04-03 Thread Jonathan Hayward http://JonathansCorner.com
Thank you! I've just added that column. Would this be an appropriate time to have an SQL stored procedure? I'm thinking pseudocode like: function count(document, list_of_keywords)     result = 1.0     if document.word_count > 0:         for keyword in list_of_keywords:     get histogram r

Re: [Sqlalchemy-users] PATCH: Microsoft SQL Server engine

2006-04-03 Thread Michael Twomey
On 4/3/06, Michael Bayer <[EMAIL PROTECTED]> wrote: > i committed the whole thing with a working version of the Alias thing i Hi Rick and Michael, Thanks for adding mssql support, I've been dying to try out sqlalchemy on some of my work servers. One thing though, I can't find mssql.py in the late

Re[4]: [Sqlalchemy-users] Problem with SELECT ... FOR UPDATE;

2006-04-03 Thread Vasily Sulatskov
Hello Michael, Monday, April 03, 2006, 11:33:13 AM, you wrote: So if I understand correctly if I want several simultaneously opened transactions I have to construct several engines? Please correct me if I am wrong. So I changed behaviour of my program to following: When tab with object opened fo