[sqlalchemy] Re: Troublesome relation

2008-06-10 Thread Paul Johnston
Hi,

 VulnResDesc.mapper.add_property('rawvulns', sao.relation(VulnRes.mapper,
 primaryjoin = sa.and_(VulnRes.targetid == VulnResDesc.targetid,
VulnMap.vulndescid == VulnResDesc.id,
VulnMap.tool == VulnRes.tool,
VulnMap.toolvulnid == VulnRes.toolvulnid),
 foreign_keys = [VulnResDesc.c.targetid, VulnResDesc.c.id],
 viewonly = True,
 uselist = True))

 ultimately all relations distill the join condition into a set of pairs,
 above it would be:
 [ (VulnResDesc.targetid, VulnRes.targetid) ]


I still don't quite understand this I'm afraid, I though there were more
columns involved - VulnResDesc.id, VulnRes.tool, VulnRes.toolvulnid.


 So using foreign_keys which only deals with these columns should probably
 work by itself:
 foreign_keys = [VulnResDesc.targetid]
 The remote_side argument, if needed, would be remote_side=
 [VulnRes.targetid] since that is the right side of the relation.


Ok, if I set foreign_keys like that, it doesn't ask me for a remote_side,
BUT when I come to actually use the relation, the query runs for a long
time, in fact my web app times out before it completes.

Have you got any other suggestions? I am pretty damn stuck here. And the
bugger is, this used to work just fine!

Paul

--~--~-~--~~~---~--~~
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: Troublesome relation

2008-06-10 Thread Paul Johnston
Hi,

I still don't quite understand this I'm afraid, I though there were more
 columns involved - VulnResDesc.id, VulnRes.tool, VulnRes.toolvulnid.


So you know, this isn't urgent now. I've rewritten the mapper property as a
property on my class, and that works straight off, without any voodoo.

But I am still interested in any thoughts you have - obviously a proper
relation is the way to do if I want to use the eagerloaded in future, for
example.

Paul

--~--~-~--~~~---~--~~
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: Ordering null dates

2008-06-10 Thread Cito

Only for the record: I just noticed that another simple workaround is
ordering by something like start_date is not null, start_date,
end_date is null, end_date. SA could also implement nullsfirst()/
nullslast() that way if the database engine does not support nulls
first/nulls last.
--~--~-~--~~~---~--~~
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: sqlalchemy in virtualenv Instructions

2008-06-10 Thread King Simon-NFHD78

Lukasz Szybalski wrote:
 
 
 I have mysqldb installed in the system wide install how do I tell
 virtualenv to use it?
 I don't see a need to install it in virtualenv again so I guess I just
 have to givea right path? How, and in which file?
 
 Thanks,
 Lucas
 
 
  File 
 /usr/local/pythonenv/BASELINE/lib/python2.4/site-packages/SQL
Alchemy-0.4.6dev_r4675-py2.4.egg/sqlalchemy/databases/mysql.py,
 line 1430, in dbapi
 import MySQLdb as mysql
 ImportError: No module named MySQLdb
 

When you create the virtualenv, there is a '--no-site-packages' switch
which determines whether the system-wide site-packages directory will be
on the search path or not. If you didn't provide this switch, then
MySQLdb should be visible. (Documented at
http://pypi.python.org/pypi/virtualenv#the-no-site-packages-option)

From your python prompt, type import sys; print '\n'.join(sys.path) to
see your search path. If the directory containing your MySQLdb
installation is not in there, you have a problem.

Hope that helps,

Simon

--~--~-~--~~~---~--~~
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] polymorphism without extra table

2008-06-10 Thread ml

Hi!

I have following situation: I have 3 tables which stand as a base for
other stuff:

table_virtual_categories = Table(virtual_categories, meta,
Column(id, Integer, primary_key = True),
Column(id_parent, Integer, ForeignKey(virtual_categories.id)),
Column(visible, Boolean, nullable=False, default=False),
Column(kind, String(10), nullable=False),
  )

table_virtual_items = Table(virtual_items, meta,
Column(id, Integer, primary_key = True),
Column(id_category, Integer, ForeignKey(virtual_categories.id),
  nullable=False),
Column(kind, String(10), nullable=False),
  )

table_virtual_proposals = Table(virtual_proposals, meta,
Column(id, Integer, primary_key = True),
Column(id_previous_version, Integer,
ForeignKey(virtual_proposals.id)),
Column(id_item, Integer, ForeignKey(virtual_items.id),
  nullable=False),
Column(title, Unicode(100)),
Column(dt_inserted, DateTime, nullable=False, default=func.now()),
Column(dt_valid_from, DateTime),
Column(dt_valid_to, DateTime),
Column(version, LUnicode(100), nullable=False),
Column(state, Integer, nullable=False)
  )

Now I have some situations where I need to inherit some of these tables
but I want to keep the schema category-item-proposal:

E.g. articles: I need special columns for categories and proposals but
articles (~items) have no extra columns:

table_articles_categories = Table(articles_categories, meta,
Column(id, Integer, ForeignKey(virtual_categories), primary_key
= True),
Column(description, UnicodeText),
  )

table_articles = Table(articles, meta,
Column(id, Integer, ForeignKey(virtual_items), primary_key = True)
  )

table_article_proposals = Table(article_proposals, meta,
Column(id, Integer, ForeignKey(virtual_proposals), primary_key =
True),
Column(body, UnicodeText),
  )

So as you can see the table articles is quite redundant because it has
only the primary key column but I didn't find any other way to select
articles directly from the table virtual_items according to the column
kind without joining to another specialized table. Is there any way
around this to omit the articles table?

Thanks for advices.

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



[sqlalchemy] Re: polymorphism without extra table

2008-06-10 Thread az

and you mappers look like?
why u need to inherit articles at all then? just use the base..

On Tuesday 10 June 2008 15:34:21 ml wrote:
 Hi!

 I have following situation: I have 3 tables which stand as a base
 for other stuff:

 table_virtual_categories = Table(virtual_categories, meta,
 Column(id, Integer, primary_key = True),
 Column(id_parent, Integer,
 ForeignKey(virtual_categories.id)), Column(visible, Boolean,
 nullable=False, default=False), Column(kind, String(10),
 nullable=False),
   )

 table_virtual_items = Table(virtual_items, meta,
 Column(id, Integer, primary_key = True),
 Column(id_category, Integer,
 ForeignKey(virtual_categories.id), nullable=False),
 Column(kind, String(10), nullable=False),
   )

 table_virtual_proposals = Table(virtual_proposals, meta,
 Column(id, Integer, primary_key = True),
 Column(id_previous_version, Integer,
 ForeignKey(virtual_proposals.id)),
 Column(id_item, Integer, ForeignKey(virtual_items.id),
   nullable=False),
 Column(title, Unicode(100)),
 Column(dt_inserted, DateTime, nullable=False,
 default=func.now()), Column(dt_valid_from, DateTime),
 Column(dt_valid_to, DateTime),
 Column(version, LUnicode(100), nullable=False),
 Column(state, Integer, nullable=False)
   )

 Now I have some situations where I need to inherit some of these
 tables but I want to keep the schema category-item-proposal:

 E.g. articles: I need special columns for categories and proposals
 but articles (~items) have no extra columns:

 table_articles_categories = Table(articles_categories, meta,
 Column(id, Integer, ForeignKey(virtual_categories),
 primary_key = True),
 Column(description, UnicodeText),
   )

 table_articles = Table(articles, meta,
 Column(id, Integer, ForeignKey(virtual_items), primary_key
 = True) )

 table_article_proposals = Table(article_proposals, meta,
 Column(id, Integer, ForeignKey(virtual_proposals),
 primary_key = True),
 Column(body, UnicodeText),
   )

 So as you can see the table articles is quite redundant because
 it has only the primary key column but I didn't find any other way
 to select articles directly from the table virtual_items
 according to the column kind without joining to another
 specialized table. Is there any way around this to omit the
 articles table?

 Thanks for advices.

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



[sqlalchemy] assocClass.linkA == A.id fails

2008-06-10 Thread az

g'day.
i stepped on strange behavour (0.4 latest):
 class AB is an assoc proxy, .myb pointing to B;
the clause 
   AB.myb == B.dbid 
fails with NotImplementedError: 
File sqlalchemy/sql/expression.py, line 1191, in __eq__
return self.operate(operators.eq, other)
  File sqlalchemy/sql/expression.py, line 1315, in operate
return o[0](self, op, other[0], *o[1:], **kwargs)
  File sqlalchemy/sql/expression.py, line 1277, in __compare
obj = self._check_literal(obj)
  File sqlalchemy/sql/expression.py, line 1421, in _check_literal
return other.expression_element()
  File sqlalchemy/orm/attributes.py, line 53, in expression_element
return self.comparator.expression_element()
  File sqlalchemy/orm/interfaces.py, line 432, in expression_element
return self.clause_element()
  File sqlalchemy/sql/expression.py, line 1170, in clause_element
raise NotImplementedError()
NotImplementedError

these work (not the .property):
 AB.myb.property == B.dbid 
 AB.myb == 3 

AB.myb.property.direction is MANYTOONE
seems i'm missing something??
any idea or prepare a test case?
svilen

--~--~-~--~~~---~--~~
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: Troublesome relation

2008-06-10 Thread Michael Bayer

On Jun 10, 2008, at 4:29 AM, Paul Johnston wrote:

 Hi,
 VulnResDesc.mapper.add_property('rawvulns',  
 sao.relation(VulnRes.mapper,
 primaryjoin = sa.and_(VulnRes.targetid == VulnResDesc.targetid,
VulnMap.vulndescid == VulnResDesc.id,
VulnMap.tool == VulnRes.tool,
VulnMap.toolvulnid == VulnRes.toolvulnid),
 foreign_keys = [VulnResDesc.c.targetid, VulnResDesc.c.id],
 viewonly = True,
 uselist = True))
 ultimately all relations distill the join condition into a set of  
 pairs, above it would be:
 [ (VulnResDesc.targetid, VulnRes.targetid) ]

 I still don't quite understand this I'm afraid, I though there were  
 more columns involved - VulnResDesc.id, VulnRes.tool,  
 VulnRes.toolvulnid.

 So using foreign_keys which only deals with these columns should  
 probably work by itself:
 foreign_keys = [VulnResDesc.targetid]
 The remote_side argument, if needed, would be remote_side=  
 [VulnRes.targetid] since that is the right side of the relation.

 Ok, if I set foreign_keys like that, it doesn't ask me for a  
 remote_side, BUT when I come to actually use the relation, the query  
 runs for a long time, in fact my web app times out before it  
 completes.

in that case you'd probably want to set remote_side as well.   the  
query running forever implies that the lazyload isnt actually putting  
a bind parameter in anywhere.

To see how these settings translate in the propertyloader, you can  
turn on  
logging 
..logging 
.getLogger('sqlalchemy.orm.properties').setLevel(logging.INFO) .


--~--~-~--~~~---~--~~
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: assocClass.linkA == A.id fails

2008-06-10 Thread Michael Bayer


manytoone should be fine.  try making a simplified test case (just any  
old many to one).

On Jun 10, 2008, at 9:39 AM, [EMAIL PROTECTED] wrote:


 g'day.
 i stepped on strange behavour (0.4 latest):
 class AB is an assoc proxy, .myb pointing to B;
 the clause
   AB.myb == B.dbid
 fails with NotImplementedError:
 File sqlalchemy/sql/expression.py, line 1191, in __eq__
return self.operate(operators.eq, other)
  File sqlalchemy/sql/expression.py, line 1315, in operate
return o[0](self, op, other[0], *o[1:], **kwargs)
  File sqlalchemy/sql/expression.py, line 1277, in __compare
obj = self._check_literal(obj)
  File sqlalchemy/sql/expression.py, line 1421, in _check_literal
return other.expression_element()
  File sqlalchemy/orm/attributes.py, line 53, in expression_element
return self.comparator.expression_element()
  File sqlalchemy/orm/interfaces.py, line 432, in expression_element
return self.clause_element()
  File sqlalchemy/sql/expression.py, line 1170, in clause_element
raise NotImplementedError()
 NotImplementedError

 these work (not the .property):
 AB.myb.property == B.dbid
 AB.myb == 3

 AB.myb.property.direction is MANYTOONE
 seems i'm missing something??
 any idea or prepare a test case?
 svilen

 


--~--~-~--~~~---~--~~
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: polymorphism without extra table

2008-06-10 Thread Michael Bayer


On Jun 10, 2008, at 8:34 AM, ml wrote:


 So as you can see the table articles is quite redundant because it  
 has
 only the primary key column but I didn't find any other way to select
 articles directly from the table virtual_items according to the  
 column
 kind without joining to another specialized table. Is there any way
 around this to omit the articles table?

dont put any table in the Article mapper. It will inherit from the  
base using single table inheritance.


--~--~-~--~~~---~--~~
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: polymorphism without extra table

2008-06-10 Thread ml

that's it! great, thanks!


Michael Bayer napsal(a):
 
 On Jun 10, 2008, at 8:34 AM, ml wrote:
 
 So as you can see the table articles is quite redundant because it  
 has
 only the primary key column but I didn't find any other way to select
 articles directly from the table virtual_items according to the  
 column
 kind without joining to another specialized table. Is there any way
 around this to omit the articles table?
 
 dont put any table in the Article mapper. It will inherit from the  
 base using single table inheritance.
 

--~--~-~--~~~---~--~~
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: sqlalchemy in virtualenv Instructions

2008-06-10 Thread Lukasz Szybalski

On Tue, Jun 10, 2008 at 6:12 AM, King Simon-NFHD78
[EMAIL PROTECTED] wrote:

 Lukasz Szybalski wrote:


 I have mysqldb installed in the system wide install how do I tell
 virtualenv to use it?
 I don't see a need to install it in virtualenv again so I guess I just
 have to givea right path? How, and in which file?

 Thanks,
 Lucas


  File
 /usr/local/pythonenv/BASELINE/lib/python2.4/site-packages/SQL
 Alchemy-0.4.6dev_r4675-py2.4.egg/sqlalchemy/databases/mysql.py,
 line 1430, in dbapi
 import MySQLdb as mysql
 ImportError: No module named MySQLdb


 When you create the virtualenv, there is a '--no-site-packages' switch
 which determines whether the system-wide site-packages directory will be
 on the search path or not. If you didn't provide this switch, then
 MySQLdb should be visible. (Documented at
 http://pypi.python.org/pypi/virtualenv#the-no-site-packages-option)

 From your python prompt, type import sys; print '\n'.join(sys.path)

Your command actually doesn't show the virtualenv? Is that how it
suppossed to be?
:~$ source /usr/local/pythonenv/BASELINE/bin/activate
(BASELINE)[EMAIL PROTECTED]:~$ python
Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type help, copyright, credits or license for more information.
 import sys; print '\n'.join(sys.path)

/usr/lib/python2.4/site-packages/Dabo-0.8.3-py2.4.egg
/usr/lib/python2.4/site-packages/pyodbc-0.0.0-py2.4-linux-i686.egg
/usr/lib/python2.4/site-packages/Sphinx-0.1.61950-py2.4.egg
/usr/lib/python2.4/site-packages/Pygments-0.9-py2.4.egg
/usr/lib/python24.zip
/usr/lib/python2.4
/usr/lib/python2.4/plat-linux2
/usr/lib/python2.4/lib-tk
/usr/lib/python2.4/lib-dynload
/usr/local/lib/python2.4/site-packages
/usr/lib/python2.4/site-packages
/usr/lib/python2.4/site-packages/Numeric
/usr/lib/python2.4/site-packages/cairo
/var/lib/python-support/python2.4
/usr/lib/python2.4/site-packages/gtk-2.0
/var/lib/python-support/python2.4/gtk-2.0
/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode



What I did is I regenerated the virtual env without the
no-site-package part, (leaving everything the way it was, just
rerunning the command) which added the system packages. I hope now
when I do easy_install -U somesystempackage it will install the
upgrade into the virtualenv location.

Lucas

--~--~-~--~~~---~--~~
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: Insertion order not respecting FK relation

2008-06-10 Thread Michael Bayer



On Jun 10, 10:34 am, Malthe Borch [EMAIL PROTECTED] wrote:
 I have an issue with SQLAlchemy planning to execute insertion tasks in
 the wrong order.

 Basically, I have a utility table Relations which is used to maintain
   ordered list relations:

 table = rdb.Table(
'relation',
metadata,
rdb.Column('id', rdb.Integer, primary_key=True, autoincrement=True),
rdb.Column('left', rdb.String(length=32),
   rdb.ForeignKey(soup.uuid), index=True),
rdb.Column('right', rdb.String(length=32),
   rdb.ForeignKey(soup.uuid)),
rdb.Column('order', rdb.Integer, nullable=False))

 Now, I append a new, transient object to such an ordered list. That
 means that SQLAlchemy would make two inserts. The problem is that the
 tasks are ordered such that the *relation* is inserted before the object
 that is the target of the relation!

 This obviously raises an IntegrityError, since the foreign key
 constraint is not satisfied.

 My question is then: How do I tell SQLAlchemy to order them correctly?

 \malthe

A self-referential relationship, when configured as many-to-one,
requires the remote_side argument to indicate this, as described in
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_selfreferential
.  Otherwise it defaults to one-to-many.

--~--~-~--~~~---~--~~
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: Insertion order not respecting FK relation

2008-06-10 Thread Malthe Borch

Michael Bayer wrote:
 A self-referential relationship, when configured as many-to-one,
 requires the remote_side argument to indicate this, as described in
 http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_selfreferential
 .  Otherwise it defaults to one-to-many.

That sounds correct, but this was not about a self-referential 
relationship. The Relations table maps a one-to-many relationship from 
some object to a number of objects (ordered).

Or am I missing something?

\malthe


--~--~-~--~~~---~--~~
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] select + is not

2008-06-10 Thread Jonathan Vanasco

this should be straightforward, I think...

I'm trying to do

select email_address from user where is_verified is not true
( or is not null or is not false )


This part is simple :
   Session.execute( sqlalchemy.select( [ User.c.email ] ) )

This part is not:
 
Session.execute( sqlalchemy.select( [ User.c.email ] , 
.User.c.is_verified.#  ) )

I can't figure that last bit out.  There's nothing in
ColumnOperators , and the is not , is stuff seems to be tucked
away in literals.

can anyone give me a suggestion?

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: assocClass.linkA == A.id fails

2008-06-10 Thread az
funny... just a plain relation, i've removed all the assoc stuff...
what i am missing???

here the case, attached.
no matter what, i doesnot work; older sa versions give different 
error...

On Tuesday 10 June 2008 16:59:01 Michael Bayer wrote:
 manytoone should be fine.  try making a simplified test case (just
 any old many to one).

 On Jun 10, 2008, at 9:39 AM, [EMAIL PROTECTED] wrote:
  g'day.
  i stepped on strange behavour (0.4 latest):
  class AB is an assoc proxy, .myb pointing to B;
  the clause
AB.myb == B.dbid
  fails with NotImplementedError:
  File sqlalchemy/sql/expression.py, line 1191, in __eq__
 return self.operate(operators.eq, other)
   File sqlalchemy/sql/expression.py, line 1315, in operate
 return o[0](self, op, other[0], *o[1:], **kwargs)
   File sqlalchemy/sql/expression.py, line 1277, in __compare
 obj = self._check_literal(obj)
   File sqlalchemy/sql/expression.py, line 1421, in
  _check_literal return other.expression_element()
   File sqlalchemy/orm/attributes.py, line 53, in
  expression_element return self.comparator.expression_element()
   File sqlalchemy/orm/interfaces.py, line 432, in
  expression_element return self.clause_element()
   File sqlalchemy/sql/expression.py, line 1170, in
  clause_element raise NotImplementedError()
  NotImplementedError
 
  these work (not the .property):
  AB.myb.property == B.dbid
  AB.myb == 3
 
  AB.myb.property.direction is MANYTOONE
  seems i'm missing something??
  any idea or prepare a test case?
  svilen

 


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



aa.py
Description: application/python


[sqlalchemy] Re: sqlalchemy + IBM DB2 + OS X 10.5

2008-06-10 Thread tarun . pasrija

Hi Binglmar

I have replied to your post on IBM_DB Forum. Please Check out if you
have missed it on

http://groups.google.com/group/ibm_db/browse_thread/thread/4095e6ecfde7e63/535519afa04bf5db?hl=en#535519afa04bf5db

Kindly let us know your thoughts.

Thanks and Regards
Tarun Pasrija


On Jun 8, 6:32 pm, Bingimar [EMAIL PROTECTED] wrote:
 Hi,

 I'm new to this group, but I was wondering... I've been reading about
 the sqlalchemy and the db2, but according to the IBM tutorial, you
 need to install the db2 on the machine that you are developing for.

 So my questin is, is it possible to use sqlalchemy, db2 and a mac?

 kind regards
 Bjarni I.

--~--~-~--~~~---~--~~
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] Performance problem with Psyco

2008-06-10 Thread Artur Siekielski

Hi.

I'm using Python 2.5.1 + SQLAlchemy + Psyco 1.6 for accelerating
Python computations. Everything works ok for SQLAchemy 0.4.4 (50%
performance boost), but for SQLAlchemy 0.4.5, 0.4.6 and latest SVN
version (0_4 branch) there is a huge slowdown and profiling shows that
SA's code takes much time:

   ncalls  tottime  percall  cumtime  percall
filename:lineno(function)
10.0000.000   98.840   98.840 string:1(module)
10.0010.001   98.840   98.840 {execfile}
10.0520.052   98.837   98.837 model/bin/run_dbwork.py:
4(module)
 14791.9440.001   88.7240.060 /home/users/artur/md/
system/trunk/model/... (_yieldData)
 4202   84.1820.020   85.1260.020 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/sql/util.py:
7(sort_tables)
 21062.4460.001   46.5550.022 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/mapper.py:
979(_save_obj)
 20960.1330.000   42.6900.020 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/mapper.py:
1226(_delete_obj)
 16470.3030.0009.7670.006 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/scoping.py:
97(do)
   1606371.3310.0003.0480.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/unitofwork.py:
605(collection)
171720.7420.0002.5010.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/unitofwork.py:
859(preexecute)
   1450720.9920.0001.4710.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/unitofwork.py:
521(polymorphic_tasks)
 14780.0120.0001.1570.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/session.py:
944(_cascade_save_or_update)
 14780.0270.0001.1450.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/session.py:
1236(_cascade_iterator)
 14780.3190.0001.1230.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/sql/compiler.py:
625(_get_colparams)
 14780.4970.0001.1150.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/mapper.py:
1309(cascade_iterator)
133020.5880.0000.6890.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/sql/compiler.py:
631(create_bind_param)
 88680.3600.0000.4940.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/properties.py:
438(cascade_iterator)
 15080.0830.0000.4870.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/query.py:
945(iterate_instances)


For comparison here is profile stats dump for the same data processed
using SA 0.4.4:

   ncalls  tottime  percall  cumtime  percall
filename:lineno(function)
10.0000.000   15.430   15.430 string:1(module)
10.0010.001   15.430   15.430 {execfile}
10.0500.050   15.427   15.427 model/bin/run_dbwork.py:
4(module)
 14691.8270.001   13.0580.009 /home/users/artur/md/
system/trunk/model/... (_yieldData)
 20802.4380.0015.3510.003 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/mapper.py:
914(_save_obj)
   1590411.2530.0002.9380.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/unitofwork.py:
620(collection)
 41470.4120.0002.7790.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/sql/util.py:
7(sort_tables)
169600.7260.0002.4280.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/unitofwork.py:
874(preexecute)
 42881.4180.0002.3470.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/sql/visitors.py:
50(traverse)
 16350.2920.0001.9960.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/scoping.py:
97(do)
 20670.0970.0001.4780.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/mapper.py:
1152(_delete_obj)
   1432620.9710.0001.4420.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/unitofwork.py:
531(polymorphic_tasks)
 14680.3090.0001.0900.001 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/sql/compiler.py:
653(_get_colparams)
 14680.0150.0000.6970.000 /usr/share/python2.5/
site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/session.py:
922(_cascade_save_or_update)
 14680.0230.0000.6820.000 /usr/share/python2.5/

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Michael Bayer

would need to see mappings.


On Jun 10, 2008, at 11:06 AM, Malthe Borch wrote:


 Michael Bayer wrote:
 A self-referential relationship, when configured as many-to-one,
 requires the remote_side argument to indicate this, as described in
 http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_selfreferential
 .  Otherwise it defaults to one-to-many.

 That sounds correct, but this was not about a self-referential
 relationship. The Relations table maps a one-to-many relationship  
 from
 some object to a number of objects (ordered).

 Or am I missing something?

 \malthe


 


--~--~-~--~~~---~--~~
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 calculate the size of the Oracle and PostgreSQL schema !!!!!

2008-06-10 Thread Paul Johnston

Hi,

My development team and me are working in a application to migrate Oracle 
databases to PostgreSQL databases, and we need this information to do this.
  

I've done successful migrations using autocode, 
http://code.google.com/p/sqlautocode/

The procedure, roughly is:
1) Use autocode to generate sqlalchemy definitions from your existing 
database
2) Create the tables in a new database - which can be a different kind 
of database
3) Use a sqlalchemy program to copy the table data

As for the program to use for (3), I've used a throwaway script, but I 
think there's something in dbcook 
(http://pypi.python.org/pypi/dbcook/0.2) you could use.

Paul


--~--~-~--~~~---~--~~
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: select db engine with create_session

2008-06-10 Thread King Simon-NFHD78

 -Original Message-
 From: sqlalchemy@googlegroups.com 
 [mailto:[EMAIL PROTECTED] On Behalf Of lilo
 Sent: 10 June 2008 17:23
 To: sqlalchemy
 Subject: [sqlalchemy] select db engine with create_session
 
 
 can someone tell me how session chooses the right db engine to insert
 records in this example:
 http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/exampl
 es/sharding/attribute_shard.py#L184?
 

(I've never used the sharding support before, so this is a guess)

On line 150, the create_session factory function gets configured with
the shard_chooser, id_chooser and query_chooser functions. The
shard_chooser function is defined on line 111 and looks like this:

111 def shard_chooser(mapper, instance, clause=None):
112 if isinstance(instance, WeatherLocation):
113 return shard_lookup[instance.continent]
114 else:
115 return shard_chooser(mapper, instance.location)

So if the instance being saved is a WeatherLocation object, then the
shard_lookup dictionary is used to return the appropriate db engine.
Otherwise, the instance is assumed to be a Report object, and so it
calls itself recursively with the Report's location.

I hope that helps - I'm sure someone will correct me if I'm wrong.

Simon

--~--~-~--~~~---~--~~
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 calculate the size of the Oracle and PostgreSQL schema !!!!!

2008-06-10 Thread az

On Tuesday 10 June 2008 20:22:08 Paul Johnston wrote:
 Hi,

 My development team and me are working in a application to migrate
  Oracle databases to PostgreSQL databases, and we need this
  information to do this.

 I've done successful migrations using autocode,
 http://code.google.com/p/sqlautocode/

 The procedure, roughly is:
 1) Use autocode to generate sqlalchemy definitions from your
 existing database
 2) Create the tables in a new database - which can be a different
 kind of database
 3) Use a sqlalchemy program to copy the table data

 As for the program to use for (3), I've used a throwaway script,
 but I think there's something in dbcook
 (http://pypi.python.org/pypi/dbcook/0.2) you could use.
it also has autocode-like script called autoload (will need touching 
for back-mapping oracle types), a schema and data copiers, and a 
metadata-diff; 
see dbcook/misc/metadata/; these are all using plain sqlalchemy.
e.g.
$ python copyall.py srcurl desturl
will (eventualy) autoload and copy everything

--~--~-~--~~~---~--~~
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: select + is not

2008-06-10 Thread Michael Bayer

what DB backend ?  often you can just compare to 1 or 0.


On Jun 10, 2008, at 12:03 PM, Jonathan Vanasco wrote:


 this should be straightforward, I think...

 I'm trying to do

 select email_address from user where is_verified is not true
 ( or is not null or is not false )


 This part is simple :
   Session.execute( sqlalchemy.select( [ User.c.email ] ) )

 This part is not:

 Session
 .execute
 ( sqlalchemy
 .select( [ User.c.email ] , .User.c.is_verified.#  ) )

 I can't figure that last bit out.  There's nothing in
 ColumnOperators , and the is not , is stuff seems to be tucked
 away in literals.

 can anyone give me a suggestion?

 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: Performance problem with Psyco

2008-06-10 Thread Michael Bayer

these two stack traces appear to show completely different operations  
proceeding (in one its a flush with a delete occuring, the other its  
performing an INSERT or UPDATE).

my vague understanding of psyco is that it can be quite arbitrary as  
to what kind of code it can improve and what kinds it cannot.   
Therefore SA can never really make any guarantee of psyco working  
exactly the same way across releases.

There has been very little changed as far as the flush() procedure  
across 0.4.4 and 0.4.5, except for some cascade fixes regarding  
orphans (detailed in CHANGES).  I would first take a look at the SQL  
being issued as the first source of speed differences;  if in 0.4.5  
there's suddenly a whole series of deletes occuring which do not  
within 0.4.4, then that's the source of the difference.



On Jun 10, 2008, at 1:09 PM, Artur Siekielski wrote:


 Hi.

 I'm using Python 2.5.1 + SQLAlchemy + Psyco 1.6 for accelerating
 Python computations. Everything works ok for SQLAchemy 0.4.4 (50%
 performance boost), but for SQLAlchemy 0.4.5, 0.4.6 and latest SVN
 version (0_4 branch) there is a huge slowdown and profiling shows that
 SA's code takes much time:

   ncalls  tottime  percall  cumtime  percall
 filename:lineno(function)
10.0000.000   98.840   98.840 string:1(module)
10.0010.001   98.840   98.840 {execfile}
10.0520.052   98.837   98.837 model/bin/run_dbwork.py:
 4(module)
 14791.9440.001   88.7240.060 /home/users/artur/md/
 system/trunk/model/... (_yieldData)
 4202   84.1820.020   85.1260.020 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/sql/util.py:
 7(sort_tables)
 21062.4460.001   46.5550.022 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/mapper.py:
 979(_save_obj)
 20960.1330.000   42.6900.020 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/mapper.py:
 1226(_delete_obj)
 16470.3030.0009.7670.006 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/scoping.py:
 97(do)
   1606371.3310.0003.0480.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/unitofwork.py:
 605(collection)
171720.7420.0002.5010.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/unitofwork.py:
 859(preexecute)
   1450720.9920.0001.4710.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/unitofwork.py:
 521(polymorphic_tasks)
 14780.0120.0001.1570.001 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/session.py:
 944(_cascade_save_or_update)
 14780.0270.0001.1450.001 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/session.py:
 1236(_cascade_iterator)
 14780.3190.0001.1230.001 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/sql/compiler.py:
 625(_get_colparams)
 14780.4970.0001.1150.001 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/mapper.py:
 1309(cascade_iterator)
133020.5880.0000.6890.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/sql/compiler.py:
 631(create_bind_param)
 88680.3600.0000.4940.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/properties.py:
 438(cascade_iterator)
 15080.0830.0000.4870.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.6-py2.5.egg/sqlalchemy/orm/query.py:
 945(iterate_instances)


 For comparison here is profile stats dump for the same data processed
 using SA 0.4.4:

   ncalls  tottime  percall  cumtime  percall
 filename:lineno(function)
10.0000.000   15.430   15.430 string:1(module)
10.0010.001   15.430   15.430 {execfile}
10.0500.050   15.427   15.427 model/bin/run_dbwork.py:
 4(module)
 14691.8270.001   13.0580.009 /home/users/artur/md/
 system/trunk/model/... (_yieldData)
 20802.4380.0015.3510.003 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/mapper.py:
 914(_save_obj)
   1590411.2530.0002.9380.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/unitofwork.py:
 620(collection)
 41470.4120.0002.7790.001 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/sql/util.py:
 7(sort_tables)
169600.7260.0002.4280.000 /usr/share/python2.5/
 site-packages/SQLAlchemy-0.4.4-py2.5.egg/sqlalchemy/orm/unitofwork.py:
 874(preexecute)
 42881.4180.0002.3470.001 /usr/share/python2.5/
 

[sqlalchemy] Re: assocClass.linkA == A.id fails

2008-06-10 Thread Michael Bayer

these are the valid comparisons:

print AB.this == A()
print AB.this_id == A.name



On Jun 10, 2008, at 8:32 AM, [EMAIL PROTECTED] wrote:

 funny... just a plain relation, i've removed all the assoc stuff...
 what i am missing???

 here the case, attached.
 no matter what, i doesnot work; older sa versions give different
 error...

 On Tuesday 10 June 2008 16:59:01 Michael Bayer wrote:
 manytoone should be fine.  try making a simplified test case (just
 any old many to one).

 On Jun 10, 2008, at 9:39 AM, [EMAIL PROTECTED] wrote:
 g'day.
 i stepped on strange behavour (0.4 latest):
 class AB is an assoc proxy, .myb pointing to B;
 the clause
  AB.myb == B.dbid
 fails with NotImplementedError:
 File sqlalchemy/sql/expression.py, line 1191, in __eq__
   return self.operate(operators.eq, other)
 File sqlalchemy/sql/expression.py, line 1315, in operate
   return o[0](self, op, other[0], *o[1:], **kwargs)
 File sqlalchemy/sql/expression.py, line 1277, in __compare
   obj = self._check_literal(obj)
 File sqlalchemy/sql/expression.py, line 1421, in
 _check_literal return other.expression_element()
 File sqlalchemy/orm/attributes.py, line 53, in
 expression_element return self.comparator.expression_element()
 File sqlalchemy/orm/interfaces.py, line 432, in
 expression_element return self.clause_element()
 File sqlalchemy/sql/expression.py, line 1170, in
 clause_element raise NotImplementedError()
 NotImplementedError

 these work (not the .property):
 AB.myb.property == B.dbid
 AB.myb == 3

 AB.myb.property.direction is MANYTOONE
 seems i'm missing something??
 any idea or prepare a test case?
 svilen




 
 aa.py


--~--~-~--~~~---~--~~
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: Performance problem with Psyco

2008-06-10 Thread Artur Siekielski



On Jun 10, 8:11 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 I would first take a look at the SQL  
 being issued as the first source of speed differences;  if in 0.4.5  
 there's suddenly a whole series of deletes occuring which do not  
 within 0.4.4, then that's the source of the difference.

SQL is the same. These differences are also when I don't flush the
Session. Also performance when not using Psyco is the same in 0.4.4
and 0.4.5. But switching Psyco on in 0.4.4 causes 50% performance
increase and in 0.4.5 about 1000% decrease.
--~--~-~--~~~---~--~~
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: assocClass.linkA == A.id fails

2008-06-10 Thread az

 these are the valid comparisons:

 print AB.this == A()
mmh. i want these to be clauses, not plain comparisons
i.e. AB.this==A.dbid --- same as tableAB.c.this==tableA.c.dbid
instead it produces something like 
:param_1 = AB.this_id

 print AB.this_id == A.name
and.. why this way works and the other way not?
and same thing as above, this is not the clause i expect.

 On Jun 10, 2008, at 8:32 AM, [EMAIL PROTECTED] wrote:
  funny... just a plain relation, i've removed all the assoc
  stuff... what i am missing???
 
  here the case, attached.
  no matter what, i doesnot work; older sa versions give different
  error...
 
  On Tuesday 10 June 2008 16:59:01 Michael Bayer wrote:
  manytoone should be fine.  try making a simplified test case
  (just any old many to one).
 
  On Jun 10, 2008, at 9:39 AM, [EMAIL PROTECTED] wrote:
  g'day.
  i stepped on strange behavour (0.4 latest):
  class AB is an assoc proxy, .myb pointing to B;
  the clause
   AB.myb == B.dbid
  fails with NotImplementedError:
  File sqlalchemy/sql/expression.py, line 1191, in __eq__
return self.operate(operators.eq, other)
  File sqlalchemy/sql/expression.py, line 1315, in operate
return o[0](self, op, other[0], *o[1:], **kwargs)
  File sqlalchemy/sql/expression.py, line 1277, in __compare
obj = self._check_literal(obj)
  File sqlalchemy/sql/expression.py, line 1421, in
  _check_literal return other.expression_element()
  File sqlalchemy/orm/attributes.py, line 53, in
  expression_element return self.comparator.expression_element()
  File sqlalchemy/orm/interfaces.py, line 432, in
  expression_element return self.clause_element()
  File sqlalchemy/sql/expression.py, line 1170, in
  clause_element raise NotImplementedError()
  NotImplementedError
 
  these work (not the .property):
  AB.myb.property == B.dbid
  AB.myb == 3
 
  AB.myb.property.direction is MANYTOONE
  seems i'm missing something??
  any idea or prepare a test case?
  svilen
 
  aa.py

 


--~--~-~--~~~---~--~~
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: Performance problem with Psyco

2008-06-10 Thread az

On Tuesday 10 June 2008 22:13:04 Artur Siekielski wrote:
 On Jun 10, 8:11 pm, Michael Bayer [EMAIL PROTECTED] wrote:
  I would first take a look at the SQL  
  being issued as the first source of speed differences;  if in
  0.4.5   there's suddenly a whole series of deletes occuring which
  do not within 0.4.4, then that's the source of the difference.

 SQL is the same. These differences are also when I don't flush the
 Session. Also performance when not using Psyco is the same in 0.4.4
 and 0.4.5. But switching Psyco on in 0.4.4 causes 50% performance
 increase and in 0.4.5 about 1000% decrease.

well.. see the difference, the function that eats the time is 
sql.sort_tables. all else is nearly same.
compare the two sources and see for yourself.
the sort_tables() itself seems same, but traversing (recursive) has 
changed a lot. from depth first into breadth first or similar.

something is going on there.

AFAIremember psyco can optimize loops and arithmetics but is very bad 
with func-calls.

profile both versions of that function without psyco and see what's 
difference in funccalls etc.

ciao

svilen

--~--~-~--~~~---~--~~
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: Insertion order not respecting FK relation

2008-06-10 Thread Malthe Borch

Michael Bayer wrote:
 would need to see mappings.

First, let me mention that this issue only occurs on Postgres; I can't 
replicate it on SQLite.

This is the many-to-many relation table (posted previously):


table = rdb.Table(
'relation',
metadata,
rdb.Column('id', rdb.Integer, primary_key=True, autoincrement=True),
rdb.Column('left', rdb.String(length=32),
   rdb.ForeignKey(soup.uuid), index=True),
rdb.Column('right', rdb.String(length=32),
   rdb.ForeignKey(soup.uuid)),
rdb.Column('order', rdb.Integer, nullable=False))

The soup table:


table = rdb.Table(
 'soup',
 metadata,
 rdb.Column('id', rdb.Integer, primary_key=True, autoincrement=True),
 rdb.Column('uuid', rdb.String(length=32), unique=True, index=True),
 rdb.Column('spec', rdb.String, index=True),
 )


The relation property that should behave like an ordered list:
-

orm.relation(
  bootstrap.Relation,
  primaryjoin=soup_table.c.uuid==relation_table.c.left,
  collection_class=RelationList,
  enable_typechecks=False)

I reproduce the problem like so:

1) Append some new item to the list, save and commit.
2) Repeat (1); an ``IntegrityError`` is raised:

IntegrityError: (IntegrityError) insert or update on table relation 
violates foreign key constraint relation_right_fkey
 DETAIL:  Key (right)=(tcbb53226374211dd8a730017f2d1db9) is not 
present in table soup.
  'INSERT INTO relation (id, left, right, order) VALUES 
(%(id)s, %(left)s, %(right)s, %(order)s)' {'left': 
'tcbb31e28374211dd8a730017f2d1db9', 'right': 
'tcbb53226374211dd8a730017f2d1db9', 'order': 1, 'id': 2L}

Any clues are greatly appreciated.

\malthe


--~--~-~--~~~---~--~~
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] Latest updates in SQL server 2008 tools and techniques

2008-06-10 Thread gokul

Find the latest updates in SQL server 2008 tools and techniques. A
site for all your IT related needs such as data management, software
testing and many more

http://www.sqlserversoftware.blogspot.com

--~--~-~--~~~---~--~~
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: Latest updates in SQL server 2008 tools and techniques

2008-06-10 Thread Rick Morrison
sorry, bad mod.

--~--~-~--~~~---~--~~
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: assocClass.linkA == A.id fails

2008-06-10 Thread az

ok, so as i get it, descriptors of PropertyLoaders cannot be used in 
clauses.
any idea then how to map something like this then without going down 
to tables:
(pseudocode)

Doc.ver == ver
and (
Doc.dbid == Doc2Place.nazn and  
Doc2Place.rabmesto == ParamValueOwnership._rabotno_miasto
or
Doc.dbid == Doc2Position.nazn and (
Doc2Position.pozicia == ParamValueOwnership._pozicia
or
Doc2Position.pozicia == Position2Dept.pozicia and (
Position2Dept.otdel == ParamValueOwnership._otdel
or
Position2Dept.otdel == Dept2Dept.child and 
Dept2Dept.roditel == ParamValueOwnership._otdel
)
)
)
and ParamValueOwnership.value == ParamValue.db_id

where: 
Doc, Place, Position, Dept all have ParamValues (via m2m 
ParamValueOwnership)
Doc has Place and Position (via m2m Doc2Place, Doc2Position)
Postion has Dept (via m2m Pos2Dept)
Dept has parent Dept (via m2m Dept2Dept)
the last one is recursive, but i'll handle it somehow, adjacent sets 
or else.

another weirdness of above, the ParamValueOwnership m2m has different 
links for diff. types of owners (mutualy exclusive), because 
otherwise i get multiple inheritance. 

can i handle multiple inheritance somehow? i.e. it looks like creating 
same object via different polymorhic hierarchies..
several polymorphic mappers over the different hierarchies? will that 
work?

On Tuesday 10 June 2008 16:39:57 you wrote:
 g'day.
 i stepped on strange behavour (0.4 latest):
  class AB is an assoc proxy, .myb pointing to B;
 the clause
AB.myb == B.dbid
 fails with NotImplementedError:
 File sqlalchemy/sql/expression.py, line 1191, in __eq__
 return self.operate(operators.eq, other)
   File sqlalchemy/sql/expression.py, line 1315, in operate
 return o[0](self, op, other[0], *o[1:], **kwargs)
   File sqlalchemy/sql/expression.py, line 1277, in __compare
 obj = self._check_literal(obj)
   File sqlalchemy/sql/expression.py, line 1421, in _check_literal
 return other.expression_element()
   File sqlalchemy/orm/attributes.py, line 53, in
 expression_element return self.comparator.expression_element()
   File sqlalchemy/orm/interfaces.py, line 432, in
 expression_element return self.clause_element()
   File sqlalchemy/sql/expression.py, line 1170, in clause_element
 raise NotImplementedError()
 NotImplementedError

 these work (not the .property):
  AB.myb.property == B.dbid
  AB.myb == 3

 AB.myb.property.direction is MANYTOONE
 seems i'm missing something??
 any idea or prepare a test case?
 svilen



On Tuesday 10 June 2008 21:15:06 Michael Bayer wrote:
 these are the valid comparisons:

 print AB.this == A()
 print AB.this_id == A.name

 On Jun 10, 2008, at 8:32 AM, [EMAIL PROTECTED] wrote:
  funny... just a plain relation, i've removed all the assoc
  stuff... what i am missing???
 
  here the case, attached.
  no matter what, i doesnot work; older sa versions give different
  error...
 

  these work (note the .property):
  AB.myb.property == B.dbid
  AB.myb == 3
 
  AB.myb.property.direction is MANYTOONE
  seems i'm missing something??
  any idea or prepare a test case?
  svilen
 
  aa.py

 


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