[sqlalchemy] how to display all the tables of my DB

2007-03-21 Thread Mando

I need to display into a checkListBox (I'm writin a GUI with wxPython)
all the tables embedded in my Database.

Initially I thought that I must to do something like this:
from sqlalchemy import *
db = create_engine('sqlite:///tutorial.db')
metadata = BoundMetaData(db)
print metatada.tables
{}


but I've received only a empty dict.
What's the right method?

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



[sqlalchemy] Re: how to display all the tables of my DB

2007-03-21 Thread Paul Johnston

Hi,

The metadata only knows about the tables defined in SA. To get all the 
tables in the db, do a query like:

select([information_schema.tables.c.table_name,
information_schema.tables.c.table_schema])

Paul

but I've received only a empty dict.
What's the right method?
  



--~--~-~--~~~---~--~~
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] exec stored procedure

2007-03-21 Thread Evgeny Nesterov
How i can exec stored procedure from database (MsSql) in Pylons with
SqlAlchemy?

I try do:
c.searchResults = func.GetBlackListForPage(request.params[page], 100,
engine=model.engine).execute()

But have error:
Module portal.controllers.blacklist:*41* in query
   *if* c*.*pageCount ** *1**:*
c*.*pageCount *=* *1*
c*.*searchResults *=* func*.*GetBlackListForPage*(* request*
.*params*[*page*]**,* *100**,* engine*=* model*.*engine*)**.*execute*(**)*
Module sqlalchemy.sql:*1010* in execute
Module sqlalchemy.sql:*485* in execute
Module sqlalchemy.sql:*513* in compile
*AttributeError: 'module' object has no attribute 'compiler'*

-- 
Best regards,
Evgeny

--~--~-~--~~~---~--~~
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: memory leak with psyco

2007-03-21 Thread Greg Copeland

One of the optimizations that psyco performs is function
specialization.  It is possible this is what is occuring.  Regardless,
you should see memory consumption taper after sustained use, under the
assumption that psyco will eventually stop creating new variants of
the specialized function.  You could test this by driving your
application with a set of fixed inputs.

One of the gotchas of using psyco is memory use goes through the roof
in exchange for much improved performance.


Greg


On Mar 21, 10:49 am, Andrew Stromnov [EMAIL PROTECTED] wrote:
 Using psyco (with full() optimization) and SA (only SQL level)
 together leads to memory leak. :\

 I'm not sure, but it is probable that SA makes many functions
 (function generators?) which are optimized by psyco, but are not
 released after 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: [patch] Data partitioning via bind functions

2007-03-21 Thread Michael Bayer

this is interesting, but what would prevent the same result by  
creating different mappers for a single class using entity_name ?
thats the current way to persist multiple objects of the same class  
in different ways.

On Mar 21, 2007, at 1:15 AM, Benno Rice wrote:

 So one thing we're attempting to do in a project I'm working on is
 partitioning our data set across several databases based on object
 keys.  I've come up with a way to implement this in SQLAlchemy which
 I've provided here as a mostly-complete patch.

 Session objects now have a bind_func method which associates a
 function taking a mapper and an ORM object and returning a
 Connectable to a mapper.  When a transaction is begun on an object
 associated with that mapper, this function is called in order to work
 out which Connectable should be used to handle this object.

 The main area where I haven't been able to work this through
 completely is in the dependency handling of many-to-many  
 relationships.

 I'm very interested in what people think of this and whether they
 feel it's a candidate for inclusion in SQLAlchemy.

 The patch is against SQLAlchemy 0.3.5.



 
 sqlalchemy-partitioning.patch

 -- 
 Benno Rice
 [EMAIL PROTECTED]
 http://jeamland.net/




--~--~-~--~~~---~--~~
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: exec stored procedure

2007-03-21 Thread Michael Bayer
your model.engine argument does not seem to be a  
sqlalchemy.engine.base.Engine instance, instead it seems to be a  
python module.

On Mar 21, 2007, at 8:52 AM, Evgeny Nesterov wrote:

 How i can exec stored procedure from database (MsSql) in Pylons  
 with SqlAlchemy?

 I try do:
 c.searchResults = func.GetBlackListForPage(request.params[page],  
 100, engine=model.engine).execute()

 But have error:
 Module portal.controllers.blacklist:41 in query
   if c.pageCount  1:
 c.pageCount = 1
 c.searchResults = func.GetBlackListForPage 
 ( request.params[page], 100, engine= model.engine).execute()
 Module sqlalchemy.sql:1010 in execute
 Module sqlalchemy.sql:485 in execute
 Module sqlalchemy.sql:513 in compile
 AttributeError: 'module' object has no attribute 'compiler'

 -- 
 Best regards,
 Evgeny
 


--~--~-~--~~~---~--~~
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: DynamicMetaData question

2007-03-21 Thread Michael Bayer


On Mar 13, 2007, at 4:26 PM, Jonathan LaCour wrote:


 Michael Bayer wrote:

 the only change I would favor here would be to merge connect into
 MetaData, BoundMetaData and DynamicMetaData stay around for backwards
 compat for probably forever, and perhaps we add another method called
 connect_threadlocal() or something like that for people who want
 that behavior. i would like to have just one object that does the
 whole thing, now that some of the early FUD has subsided.

 To be clear: this is exactly what I want.  I like the concept
 of metadata I just don't like the fact that we have two objects
 (BoundMetaData and DynamicMetaData) that are very different in  
 terms of
 how you use them when they don't need to be.  Putting 'connect' into
 MetaData will solve my complaint nicely, and I can safely ignore the
 craziness of DynamicMetaData and redundancy of BoundMetaData for the
 rest of time.


OK, let me tell you what just happened the other day.  Im dealing  
with a Pylons application, and Pylons provides the SA engine by  
binding it to the Session.  but the application also had a  
DynamicMetaData stuck in there, and at some point they were creating  
their own engine and connecting it to the DMD.  needless to say I  
quickly got uber-confused as the app was running with *two* engines,  
which happened to point to the same database, but still completely  
weird.  So i fixed it.  But by changing the DynamicMetaData to just  
plain MetaData, i was then *sure* that no other part of the app was  
trying to sneak a connect() on there.  Whereas if we only had one  
kind MetaData I could not rely upon that.

Not sure if that justifies the existence of DMD since its Python,  
things are dynamiclaly typed, theres an endless number of operations  
that you cant really guard against.  But was just a moment that I  
felt thankful that there *were* two versions of MetaData.

--~--~-~--~~~---~--~~
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] polymorphic problem in 0.3.5

2007-03-21 Thread Toshio Kuratomi

Hi guys.

I'm using sqlalchemy with TurboGears.  The code for my project is GPL,
so if you need access to more source just let me know:

I was successfully using the following definition of a
polymorphic_union in 0.3.4::

'''
collectionJoin = polymorphic_union (
{'b' : select((CollectionTable.join(
BranchTable, CollectionTable.c.id ==
BranchTable.c.collectionid),
column('b').label('kind'))),
 'c' : select((CollectionTable, column('c').label('kind')),
 not_(CollectionTable.c.id.in_(select(
 (CollectionTable.c.id,),
 CollectionTable.c.id == BranchTable.c.collectionid)
 )))
 },
None
)
'''

In 0.3.5, this gives me errors.  Inspecting the SQL, it looks like I'm
getting this kind of select now::
  SELECT collection.id, \'c\' AS kind \nFROM collection

which isn't what I want.  I want something more like this::
  SELECT collection.id, 'c' AS kind \nFROM collection

I browse the docs and find that literal() is what I want.  I try::
'''
select((CollectionTable, literal('c').label('kind')),
 not_(CollectionTable.c.id.in_(select(
 (CollectionTable.c.id,),
 CollectionTable.c.id == BranchTable.c.collectionid)
 )))
'''

which works fine as a bare statement.  Now I plug this into my
polymorphic union::
'''
collectionJoin = polymorphic_union (
{'b' : select((CollectionTable.join(
BranchTable, CollectionTable.c.id ==
BranchTable.c.collectionid),
literal('b').label('kind'))),
 'c' : select((CollectionTable, literal('c').label('kind')),
 not_(CollectionTable.c.id.in_(select(
 (CollectionTable.c.id,),
 CollectionTable.c.id == BranchTable.c.collectionid)
 )))
 },
None
)
'''

And now I'm getting a different error::
'''
Traceback (most recent call last):
  File /var/www/repo/vanilla-fedora-packagedb/pkgdb/start-pkgdb.py,
line 25, in ?
from pkgdb.controllers import Root
  File /var/www/repo/vanilla-fedora-packagedb/pkgdb/pkgdb/
controllers.py, line 7, in ?
from pkgdb import model
  File /var/www/repo/vanilla-fedora-packagedb/pkgdb/pkgdb/model.py,
line 222, in ?
None
  File /usr/lib/python2.4/site-packages/sqlalchemy/orm/util.py, line
47, in polymorphic_union
for c in table.c:
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 779,
in lambda
c = property(lambda s:s._get_exported_attribute('_columns'))
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 776,
in _get_exported_attribute
self._export_columns()
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 801,
in _export_columns
export = self._exportable_columns()
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
1226, in _exportable_columns
return self.selectable.columns
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 778,
in lambda
columns = property(lambda s:s._get_exported_attribute('_columns'))
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 776,
in _get_exported_attribute
self._export_columns()
  File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 815,
in _export_columns
for ci in cp.orig_set:
AttributeError: '_BindParamClause' object has no attribute 'orig_set'
'''

Any ideas on how I should construct my polymorphic_union?

Thanks,
-Toshio


--~--~-~--~~~---~--~~
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: DynamicMetaData question

2007-03-21 Thread Jonathan LaCour

Michael Bayer wrote:

 OK, let me tell you what just happened the other day.  Im dealing
 with a Pylons application, and Pylons provides the SA engine by
 binding it to the Session.  but the application also had a
 DynamicMetaData stuck in there, and at some point they were creating
 their own engine and connecting it to the DMD.  needless to say I
 quickly got uber-confused as the app was running with *two* engines,
 which happened to point to the same database, but still completely
 weird.  So i fixed it.  But by changing the DynamicMetaData to just
 plain MetaData, i was then *sure* that no other part of the app was
 trying to sneak a connect() on there.  Whereas if we only had one
 kind MetaData I could not rely upon that.

So you are saying you got uber-confused because of DynamicMetaData?
Thats even more reason to not use it :)  If it confused you, its sure
to confuse me (as it already has before)!

Just joking around...

 Not sure if that justifies the existence of DMD since its Python,
 things are dynamiclaly typed, theres an endless number of operations
 that you cant really guard against.  But was just a moment that I
 felt thankful that there *were* two versions of MetaData.

I see your point.  I don't care what you do with DynamicMetaData, as
long as I can do this one day:

 metadata = MetaData()
 engine = create_engine(...)
 metadata.connect(engine)

... preferably soon ;)

--
Jonathan LaCour
http://cleverdevil.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: polymorphic problem in 0.3.5

2007-03-21 Thread Michael Bayer

the literal('c') compiles into a bind parameter, which is not able to  
export itself as a column on its enclosing selectable, so thats  
that error (i might want to look into adding a better error for that  
one, had never seen it before).  you want to use a newer function  
literal_column(c).   the change in 0.3.5 is that saying column 
(something) is going to apply case sensitivity rules to the string  
inside...since yours has '' inside of it, it says, oh i have to  
quote that.  so literal_column() disables all quoting rules (and its  
whats used inside of the polymorphic_union function now).

On Mar 21, 2007, at 3:37 PM, Toshio Kuratomi wrote:


 Hi guys.

 I'm using sqlalchemy with TurboGears.  The code for my project is GPL,
 so if you need access to more source just let me know:

 I was successfully using the following definition of a
 polymorphic_union in 0.3.4::

 '''
 collectionJoin = polymorphic_union (
 {'b' : select((CollectionTable.join(
 BranchTable, CollectionTable.c.id ==
 BranchTable.c.collectionid),
 column('b').label('kind'))),
  'c' : select((CollectionTable, column('c').label('kind')),
  not_(CollectionTable.c.id.in_(select(
  (CollectionTable.c.id,),
  CollectionTable.c.id == BranchTable.c.collectionid)
  )))
  },
 None
 )
 '''

 In 0.3.5, this gives me errors.  Inspecting the SQL, it looks like I'm
 getting this kind of select now::
   SELECT collection.id, \'c\' AS kind \nFROM collection

 which isn't what I want.  I want something more like this::
   SELECT collection.id, 'c' AS kind \nFROM collection

 I browse the docs and find that literal() is what I want.  I try::
 '''
 select((CollectionTable, literal('c').label('kind')),
  not_(CollectionTable.c.id.in_(select(
  (CollectionTable.c.id,),
  CollectionTable.c.id == BranchTable.c.collectionid)
  )))
 '''

 which works fine as a bare statement.  Now I plug this into my
 polymorphic union::
 '''
 collectionJoin = polymorphic_union (
 {'b' : select((CollectionTable.join(
 BranchTable, CollectionTable.c.id ==
 BranchTable.c.collectionid),
 literal('b').label('kind'))),
  'c' : select((CollectionTable, literal('c').label('kind')),
  not_(CollectionTable.c.id.in_(select(
  (CollectionTable.c.id,),
  CollectionTable.c.id == BranchTable.c.collectionid)
  )))
  },
 None
 )
 '''

 And now I'm getting a different error::
 '''
 Traceback (most recent call last):
   File /var/www/repo/vanilla-fedora-packagedb/pkgdb/start-pkgdb.py,
 line 25, in ?
 from pkgdb.controllers import Root
   File /var/www/repo/vanilla-fedora-packagedb/pkgdb/pkgdb/
 controllers.py, line 7, in ?
 from pkgdb import model
   File /var/www/repo/vanilla-fedora-packagedb/pkgdb/pkgdb/model.py,
 line 222, in ?
 None
   File /usr/lib/python2.4/site-packages/sqlalchemy/orm/util.py, line
 47, in polymorphic_union
 for c in table.c:
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 779,
 in lambda
 c = property(lambda s:s._get_exported_attribute('_columns'))
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 776,
 in _get_exported_attribute
 self._export_columns()
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 801,
 in _export_columns
 export = self._exportable_columns()
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 1226, in _exportable_columns
 return self.selectable.columns
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 778,
 in lambda
 columns = property(lambda s:s._get_exported_attribute('_columns'))
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 776,
 in _get_exported_attribute
 self._export_columns()
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 815,
 in _export_columns
 for ci in cp.orig_set:
 AttributeError: '_BindParamClause' object has no attribute 'orig_set'
 '''

 Any ideas on how I should construct my polymorphic_union?

 Thanks,
 -Toshio


 


--~--~-~--~~~---~--~~
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: DynamicMetaData question

2007-03-21 Thread Michael Bayer


On Mar 21, 2007, at 3:55 PM, Jonathan LaCour wrote:


 I see your point.  I don't care what you do with DynamicMetaData, as
 long as I can do this one day:

  metadata = MetaData()
  engine = create_engine(...)
  metadata.connect(engine)

 ... preferably soon ;)


right..but just my point is, since MetaData doesnt *have* a connect()  
on it, thats what gave me the warm and fuzzy in that scenario.


--~--~-~--~~~---~--~~
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: polymorphic problem in 0.3.5

2007-03-21 Thread sdobrev

isn't polymorphic_union( { 'a': select..., 'b': select... }, 'kind' ) 
working in your case?

On Wednesday 21 March 2007 21:37:47 Toshio Kuratomi wrote:
 Hi guys.

 I'm using sqlalchemy with TurboGears.  The code for my project is
 GPL, so if you need access to more source just let me know:

 I was successfully using the following definition of a
 polymorphic_union in 0.3.4::

 '''
 collectionJoin = polymorphic_union (
 {'b' : select((CollectionTable.join(
 BranchTable, CollectionTable.c.id ==
 BranchTable.c.collectionid),
 column('b').label('kind'))),
  'c' : select((CollectionTable,
 column('c').label('kind')), not_(CollectionTable.c.id.in_(select(
  (CollectionTable.c.id,),
  CollectionTable.c.id ==
 BranchTable.c.collectionid) )))
  },
 None
 )
 '''

 In 0.3.5, this gives me errors.  Inspecting the SQL, it looks like
 I'm getting this kind of select now::
   SELECT collection.id, \'c\' AS kind \nFROM collection

 which isn't what I want.  I want something more like this::
   SELECT collection.id, 'c' AS kind \nFROM collection

 I browse the docs and find that literal() is what I want.  I try::
 '''
 select((CollectionTable, literal('c').label('kind')),
  not_(CollectionTable.c.id.in_(select(
  (CollectionTable.c.id,),
  CollectionTable.c.id ==
 BranchTable.c.collectionid) )))
 '''

 which works fine as a bare statement.  Now I plug this into my
 polymorphic union::
 '''
 collectionJoin = polymorphic_union (
 {'b' : select((CollectionTable.join(
 BranchTable, CollectionTable.c.id ==
 BranchTable.c.collectionid),
 literal('b').label('kind'))),
  'c' : select((CollectionTable,
 literal('c').label('kind')), not_(CollectionTable.c.id.in_(select(
  (CollectionTable.c.id,),
  CollectionTable.c.id ==
 BranchTable.c.collectionid) )))
  },
 None
 )
 '''

 And now I'm getting a different error::
 '''
 Traceback (most recent call last):
   File
 /var/www/repo/vanilla-fedora-packagedb/pkgdb/start-pkgdb.py, line
 25, in ?
 from pkgdb.controllers import Root
   File /var/www/repo/vanilla-fedora-packagedb/pkgdb/pkgdb/
 controllers.py, line 7, in ?
 from pkgdb import model
   File
 /var/www/repo/vanilla-fedora-packagedb/pkgdb/pkgdb/model.py, line
 222, in ?
 None
   File /usr/lib/python2.4/site-packages/sqlalchemy/orm/util.py,
 line 47, in polymorphic_union
 for c in table.c:
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 779, in lambda
 c = property(lambda s:s._get_exported_attribute('_columns'))
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 776, in _get_exported_attribute
 self._export_columns()
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 801, in _export_columns
 export = self._exportable_columns()
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 1226, in _exportable_columns
 return self.selectable.columns
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 778, in lambda
 columns = property(lambda
 s:s._get_exported_attribute('_columns')) File
 /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 776, in
 _get_exported_attribute
 self._export_columns()
   File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line
 815, in _export_columns
 for ci in cp.orig_set:
 AttributeError: '_BindParamClause' object has no attribute
 'orig_set' '''

 Any ideas on how I should construct my polymorphic_union?

 Thanks,
 -Toshio


 


--~--~-~--~~~---~--~~
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: polymorphic problem in 0.3.5

2007-03-21 Thread Toshio Kuratomi
On Wed, 2007-03-21 at 16:11 -0400, Michael Bayer wrote:
 the literal('c') compiles into a bind parameter, which is not able to  
 export itself as a column on its enclosing selectable, so thats  
 that error (i might want to look into adding a better error for that  
 one, had never seen it before).  you want to use a newer function  
 literal_column(c).   the change in 0.3.5 is that saying column 
 (something) is going to apply case sensitivity rules to the string  
 inside...since yours has '' inside of it, it says, oh i have to  
 quote that.  so literal_column() disables all quoting rules (and its  
 whats used inside of the polymorphic_union function now).

Thanks Michael! 

literal_column('c').label('kind') seems to be working well.

-Toshio


signature.asc
Description: This is a digitally signed message part


[sqlalchemy] Re: how to display all the tables of my DB

2007-03-21 Thread Paul Johnston
An example of a working script that uses this technique is here:
http://www.sqlalchemy.org/trac/attachment/wiki/UsageRecipes/AutoCode/autocode.py

Paul


On 3/21/07, Mando [EMAIL PROTECTED] wrote:


  select([information_schema.tables.c.table_name,
  information_schema.tables.c.table_schema])

 Sorry, but I don't undestand how.


--~--~-~--~~~---~--~~
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: Using mapper with custom select creates unneeded subquery

2007-03-21 Thread Michael Bayer

when you pass a selectable to the mapper, the mapper considers that  
selectable to be encapsulated, in the same way as a table is.  the  
Query cannot add any extra criterion to that selectable directly  
since it would modify the results and corrupt the meaning, if not the  
actual syntax, of the selectable itself.  therefore the mapper is  
always going to select * from (your selectable) - its the only way to  
guarantee the correct results.

the queries it generates, i.e. select * from (select * from ...))   
will be optimized by the database's optimizer in most cases and  
should not add any overhead to your application.

On Mar 21, 2007, at 8:08 PM, Koen Bok wrote:


 My mapper looks like this:

 stock_unreserved = select(
   [stock_table] + \
   [stock_table.c.quantity.op('-')
 (func.sum(request_table.c.quantity)).label('unordered')] + \
   [stock_table.c.quantity.op('-')
 (func.sum(request_table.c.allocation)).label('unallocated')],
   and_(
   request_table.c.id_item==stock_table.c.id_product,
   request_table.c.id_location==stock_table.c.id_location,
   request_table.c.id_stocktype==stock_table.c.id_stocktype),
   group_by=[c for c in stock_table.c]).alias('stock_unreserved')

 mapper(Stock, stock_unreserved, properties={
   'product': relation(Item,
 primaryjoin=item_table.c.id==stock_table.c.id_product,
 backref='_stock'),
   'location': relation(Item,
 primaryjoin=item_table.c.id==stock_table.c.id_location),
   'stocktype': relation(StockType)})

 Whenever I try to select an object through the mapper I would think it
 would use the SQL from stock_unreserved which is:

 SELECT
   stock.id,
   stock.id_stocktype,
   stock.id_product,
   stock.id_location,
   stock.quantity, (stock.quantity - sum(request.quantity)) AS
 unordered,
   (stock.quantity - sum(request.allocation)) AS unallocated
 FROM stock, request
 WHERE request.id_item = stock.id_product
 AND request.id_location = stock.id_location
 AND request.id_stocktype = stock.id_stocktype
 GROUP BY stock.id, stock.id_stocktype, stock.id_product,
 stock.id_location, stock.quantity

 Selecting all objects by a plain select() on the mapper works great!
 But when I make a selection it does a subquery on all the results eg:

 SELECT * FROM (SELECT * FROM stock_unreserved) WHERE selection
 criteria

 But I want it to append it to the other selection criteria without
 doing a subselect eg:

 SELECT * FROM stock_unreserved WERE ... AND ... + extra selection
 criteria

 Is this possible at all?

 Many thanks!

 Koen


 


--~--~-~--~~~---~--~~
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: [ticket:336] Informix support and some enhancement for oracle and pgsql

2007-03-21 Thread 张骏

 so, youd just have people using postgres automatically and without  
 any control issue a SAVEPOINT SP after every single statement  
 execution ?  what about the performance overhead ?  what if someone  
 wants to issue SAVEPOINT at some other step, or not at all ?

yes,you are right.
reject this patch please.

i only want to make the pgsql's behavior as same as oracle.
but i am not thinking over those questions. :)

-- 
james.zhang [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---