[sqlalchemy] Re: SQLAlchemy 0.3.7 released

2007-04-30 Thread ml

Excellent!

Michael Bayer napsal(a):
 0.3.7 is out and has a huge number of improvements and fixes.  some  
 of the highlights:
 
 - server side cursor support for Postgres
 - much improved auto-reconnect support
 - informix support
 - long identifier name support
 - support for unicode table/column/identifier names and SQL statements
 - deterministic label name generation
 - new query features, like with_parent()
 - improvements to custom collection mapping
 - lots more docstrings
 - major refactoring of sqlalchemy.engine internals, featuring clearer
 structural relationships, fewer codepaths, better result handling
 

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Informations about the connection state

2007-04-30 Thread Andreas Jung

Hi,

I am currently working on a deeper integration of SA into Zope 2.

Is it possible to determine if an engine has open connections to a database?

Is it possible to close all connections? This is necessary since a database 
adapter in Zope can be switched off in order to close connections (e.g. 
sometimes necessary when you need to drop a database without closing down
a Zope instances; keep in mind that Zope can be clustered and a Zope 
instance can have connections to multiple databases).


Andreas

pgptwtlq5634V.pgp
Description: PGP signature


[sqlalchemy] multiple M:N joins fails

2007-04-30 Thread ml
Hi!

I have 2 relations: 
 - recipes-categories (M:N)
 - recipes-flags (M:N)

I'd like to get something like:
SELECT recipes.title FROM recipes
  JOIN _recipes_ctgs_recipes
ON _recipes_ctgs_recipes.id_recipe = recipes.id
JOIN recipes_ctgs
  ON _recipes_ctgs_recipes.id_recipes_ctg=recipes_ctgs.id
  JOIN _recipes_flgs_recipes
ON _recipes_flgs_recipes.id_recipe = recipes.id
JOIN recipes_flgs
  ON _recipes_flgs_recipes.id_recipes_flg=recipes_flgs.id
  WHERE recipes_ctgs.title='cat1' AND recipes_flgs.title='flag1'

when I run
sess.query(Recipe).join(ctgs).join(flgs).select(...)
it fails with

sqlalchemy.exceptions.SQLError: (ProgrammingError) table name
_recipes_ctgs_recipes specified more than once

where _recipes_ctgs_recipes is a secondary table. Full example attached.

SA 0.3.7, PostgreSQL 8.1

David

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



test.tgz
Description: GNU Unix tar archive


[sqlalchemy] selectresults and activemapper : behavior changes between versions 0.3.1 and 0.3.6

2007-04-30 Thread remi jolin

Hello,

I'm using selectresults and activemapper.
in version 0.3.1 if I did something like x = 
Announces.select(Annonces.c.type==A) I got a SelectResults object.
Now (0.3.6) I get a list of Announces (the query is done immediately).
But if I don't specify anything in the select method 
(Announces.select()) I get the expected SelectResults object.

Is it the expected behavior ?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] How do you get the underlying sql (without executing it) from a Statement or a compiled_statement?

2007-04-30 Thread vinjvinj

Is there any way to have sqlalchemy return the sql that it is going to
execute without actually executing it? I'm using the statement class.

Vineet


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Executing SQL directly inside a thread local transaction?

2007-04-30 Thread Andreas Jung

I have a scenario where we I need to execute SQL directly within a
transaction that is local to a Python thread. Is there some way to this in
SA? In this particular usecase there is no UOW involved. Or is it somehow
to pass a SQL statement somehow to the session and its underlaying 
framework?


Andreas

pgpGrJOQyXlqy.pgp
Description: PGP signature


[sqlalchemy] Re: How do you get the underlying sql (without executing it) from a Statement or a compiled_statement?

2007-04-30 Thread Gaetan de Menten

Just use
print your_statement_variable

Or, if you need it in a variable: str(your_statement_variable) should
do the trick.

On 4/30/07, vinjvinj [EMAIL PROTECTED] wrote:

 Is there any way to have sqlalchemy return the sql that it is going to
 execute without actually executing it? I'm using the statement class.

 Vineet

-- 
Gaëtan de Menten
http://openhex.org

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: selectresults and activemapper : behavior changes between versions 0.3.1 and 0.3.6

2007-04-30 Thread remi jolin

Michael Bayer a écrit :
 On Apr 30, 2007, at 9:42 AM, remi jolin wrote:

   
 Hello,

 I'm using selectresults and activemapper.
 in version 0.3.1 if I did something like x =
 Announces.select(Annonces.c.type==A) I got a SelectResults object.
 Now (0.3.6) I get a list of Announces (the query is done immediately).
 But if I don't specify anything in the select method
 (Announces.select()) I get the expected SelectResults object.

 Is it the expected behavior ?

 

 its not.  I can see a small bug in SelectResultsExt that might lead  
 to this issue, so try out 2588 for that.
   
Ok, it works. Thanks Michael.
 however, SelectResults is deprecated since all of its functionality  
 is available within Query.  if you instead call Announces.query.filter 
 (Annonces.c.type==A) that would be the new usage.
   
isn't it Announces.query().filter(Annonces.c.type==A)

because your syntax gives an error AttributeError: 'function' object has no 
attribute 'filter'

TurboGears paginate is using SelectResults, not (V 1.0.1) Query.

 not to mention that ActiveMapper is deprecated in favor of Elixir  
 too :) .
   
Yes I know but my project is older than Elixir ;-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: IN() bug bit hard

2007-04-30 Thread Rick Morrison
Hey where are we with this? Does #476 fix #545, or are they unrelated? What
is the current behavior in 0.3.7 with an empty IN() list?


On 4/21/07, Michael Bayer [EMAIL PROTECTED] wrote:



 On Apr 13, 2007, at 4:17 PM, Ants Aasma wrote:

 
  I'll try to create a test suite for it next week, I have already
  identified most of the test cases. Should I attach it to #476 or
  create a new ticket?

 Ive created ticket #545 and assigned to you.  I may be putting out
 0.3.7 today or tomorrow, once i determine the state of the trunk is
 OK, so this fix may or may not be in this release depending on timing.

 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: How do you get the underlying sql (without executing it) from a Statement or a compiled_statement?

2007-04-30 Thread vinjvinj

When I print the statement it just prints the query with placeholders
for the paramters (and not the actual parameters). I would like to get
the actual sql that it is going to execute.

Vineet



On Apr 30, 10:36 am, Gaetan de Menten [EMAIL PROTECTED] wrote:
 Just use
 print your_statement_variable

 Or, if you need it in a variable: str(your_statement_variable) should
 do the trick.

 On 4/30/07, vinjvinj [EMAIL PROTECTED] wrote:



  Is there any way to have sqlalchemy return the sql that it is going to
  execute without actually executing it? I'm using the statement class.

  Vineet

 --
 Gaëtan de Mentenhttp://openhex.org


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Buildbot

2007-04-30 Thread Rick Morrison
Hi Mike,

Pursuant to our discussion on another thread regarding buildbots, I've got a
preliminary buildbot slave VM set up as follows:

Ubuntu 6.10
VMware tools
Python 2.4
Buildbot 0.7.4
Postgres 8.2.2
MySQL 5.0.37
Sqlite 3.3.17 (also known as version du semaine these days...)
FreeTDS / UnixODBC

psycopg 2.0.5.1
pysqlite 2.3.2
pyodbc 2.0.35
pymssql 0.8.0 (with some local patches to fix selectmany())
mysqldb 1.2.2
Sqlalchemy trunk

If I host the bot here, it'll also be able to access a MS-SQL 2005 server.
So all told, this botslave should be able to test:

Postgres
MySQL
Sqlite
MS-SQL via pyodbc  (Unix)
MS-SQL via pymssql (Unix)

We'll still need to arrange hosting for the buildbot master (maybe someone
with the PSF can help here?), and some slaves for Oracle, Firebird and
Informix.

Rick

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Selectable/subquery for a (scalar) column?

2007-04-30 Thread Michael Bayer



On Apr 30, 1:11 pm, Gaetan de Menten [EMAIL PROTECTED] wrote:

 There is (at least) one problem remaining though: subqueries do not
 get correlated correctly. This is because the table in the main query
 is aliased and the one in the subquery is not and that the
 correlator in the Select class does not recognize an aliased table
 as being the same as the original table.

 I see two ways to fix this:

 * The first and most easy one is to change the correlator to correlate
 aliased tables with the original ones. Attached is patch which does
 just that. But I highly suspect it's not correct to do that.

 * The other option is obviously to aliasize the table in the
 subquery... The problem with that is that the ClauseAdapter in
 sql_util simply doesn't do it... And I didn't see a way to make it do
 it since the from objects in a select are pretty much private. Any
 idea?

ticket #52 needs to be implemented first.  the work there is 5% adding
the method, 95% in creating the unit tests so that any changes to
sql.Select in the future dont break the method.

secondly, the from list of Select can be affected in two ways, by
adding a FromClause that implements _hide_froms() to conceal from
clauses which it replaces, and also by explicitly calling
correlate(from_obj) which is not quite what you need here.  but theres
no reason append_from() cant have a hides=None argument added to it
so an external actor can also indicate FROM object X masks FROM
object Y.  also theres not any huge reason there cant be a
remove_from() either.   looking at the code im seeing some possible
simplifications to the _process_froms() method which might make some
of this easier to see.

the usage of these from altering methods in sql_util would all be
just an enhancement to AbstractClauseProcessor who's usage would
become more generalized to be able to process selects and not just
binary/compound clause fragments.  the Aliasizer also i think will
soon be removed in all cases and replaced with ClauseAdapter which is
easier to use.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Executing SQL directly inside a thread local transaction?

2007-04-30 Thread Ian Charnas

Yes!  While most *any* query can be done using sqlalchemy... and you
*should* try to use sqlalchemy because then if you change databases
you won't have to go through all your code and figure out if any of
the sql is different if you're absolutely sure you really really
need to do a bare sql query, you can do this:

from sqlalchemy import *
engine = create_engine(sqlite:///test.db)
engine.execute(insert into people(first_name, last_name)
values('ian', 'charnas'))
engine.execute(select * from people).fetchall()
[(1, 'ian', 'charnas')]

note that metadata keeps track of tables, and session keeps track of
instances of mapped classes, so to do this you don't need to use
metadata or session whatsoever.

On Apr 30, 10:04 am, Andreas Jung [EMAIL PROTECTED] wrote:
 I have a scenario where we I need to execute SQL directly within a
 transaction that is local to a Python thread. Is there some way to this in
 SA? In this particular usecase there is no UOW involved. Or is it somehow
 to pass a SQL statement somehow to the session and its underlaying
 framework?

 Andreas

  application_pgp-signature_part
 1KDownload


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Executing SQL directly inside a thread local transaction?

2007-04-30 Thread Andreas Jung



--On 30. April 2007 19:34:41 + Ian Charnas [EMAIL PROTECTED] wrote:



Yes!  While most *any* query can be done using sqlalchemy... and you
*should* try to use sqlalchemy because then if you change databases
you won't have to go through all your code and figure out if any of
the sql is different if you're absolutely sure you really really
need to do a bare sql query, you can do this:

from sqlalchemy import *
engine = create_engine(sqlite:///test.db)
engine.execute(insert into people(first_name, last_name)
values('ian', 'charnas'))
engine.execute(select * from people).fetchall()
[(1, 'ian', 'charnas')]

note that metadata keeps track of tables, and session keeps track of
instances of mapped classes, so to do this you don't need to use
metadata or session whatsoever.


Creating/re-using a connection on a pre-Zope-transaction basis resolved my
problem.

Andreas

pgpFgqQBpDCtx.pgp
Description: PGP signature


[sqlalchemy] Re: multiple M:N joins fails

2007-04-30 Thread Michael Bayer


On Apr 30, 2007, at 8:40 AM, ml wrote:

 Hi!

 I have 2 relations:   
  - recipes-categories (M:N)
  - recipes-flags (M:N)

 I'd like to get something like:
 SELECT recipes.title FROM recipes
   JOIN _recipes_ctgs_recipes
 ON _recipes_ctgs_recipes.id_recipe = recipes.id
 JOIN recipes_ctgs
   ON _recipes_ctgs_recipes.id_recipes_ctg=recipes_ctgs.id
   JOIN _recipes_flgs_recipes
 ON _recipes_flgs_recipes.id_recipe = recipes.id
 JOIN recipes_flgs
   ON _recipes_flgs_recipes.id_recipes_flg=recipes_flgs.id
   WHERE recipes_ctgs.title='cat1' AND recipes_flgs.title='flag1'

 when I run
 sess.query(Recipe).join(ctgs).join(flgs).select(...)
 it fails with

 sqlalchemy.exceptions.SQLError: (ProgrammingError) table name
 _recipes_ctgs_recipes specified more than once

 where _recipes_ctgs_recipes is a secondary table. Full example  
 attached.

well, yeah, youre joining against the same relationship twice.
going from ctgs to flgs makes it essentially a self referential  
join on recipes.  i dont understand what youre trying to query for  
there but my intuition tells me theres probably some better way to  
lay out that query without 5 joins in between.  if not, youll have to  
lay out the self referential part manually using table aliases.

(note to SA old schoolers - see why i hesitated so much to add auto- 
joins across relationships ? every new feature spawns a whole new  
class of user issues)



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: IN() bug bit hard

2007-04-30 Thread Michael Bayer
#545 is all by itself.  ants was going to put in the CASE idea last  
we spoke.

On Apr 30, 2007, at 11:05 AM, Rick Morrison wrote:

 Hey where are we with this? Does #476 fix #545, or are they  
 unrelated? What is the current behavior in 0.3.7 with an empty IN()  
 list?


 On 4/21/07, Michael Bayer [EMAIL PROTECTED] wrote:


 On Apr 13, 2007, at 4:17 PM, Ants Aasma wrote:

 
  I'll try to create a test suite for it next week, I have already
  identified most of the test cases. Should I attach it to #476 or
  create a new ticket?

 Ive created ticket #545 and assigned to you.  I may be putting out
 0.3.7 today or tomorrow, once i determine the state of the trunk is
 OK, so this fix may or may not be in this release depending on timing.
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Buildbot

2007-04-30 Thread Michael Bayer

the main effort here is all the familiarizing and configuration of  
buildbots, which i have made great efforts to have no understanding  
of whatsoever.  if a buildbot master doesnt take up a lot of ram or  
CPU I could run it on SA's own host.

On Apr 30, 2007, at 11:43 AM, Rick Morrison wrote:

 Hi Mike,

 Pursuant to our discussion on another thread regarding buildbots,  
 I've got a preliminary buildbot slave VM set up as follows:

 Ubuntu 6.10
 VMware tools
 Python 2.4
 Buildbot 0.7.4
 Postgres 8.2.2
 MySQL 5.0.37
 Sqlite 3.3.17 (also known as version du semaine these days...)
 FreeTDS / UnixODBC

 psycopg 2.0.5.1
 pysqlite 2.3.2
 pyodbc 2.0.35
 pymssql 0.8.0 (with some local patches to fix selectmany())
 mysqldb 1.2.2
 Sqlalchemy trunk

 If I host the bot here, it'll also be able to access a MS-SQL 2005  
 server. So all told, this botslave should be able to test:

 Postgres
 MySQL
 Sqlite
 MS-SQL via pyodbc  (Unix)
 MS-SQL via pymssql (Unix)

 We'll still need to arrange hosting for the buildbot master (maybe  
 someone with the PSF can help here?), and some slaves for Oracle,  
 Firebird and Informix.

 Rick

 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---