[sqlalchemy] Re: Unit testing with SA?

2007-02-03 Thread sdobrev

There is more; 
to have really independent tests u have to destroy all SA caches and 
mappers etc.

metadata.drop_all()
clear_mappers()
db.dispose()
and always let ALL sessions etc fall out of scope. 

Make sure u do not store exception contexts, nor any persistent 
objects between the tests.
otherwise u may get a memory leaking.

see ticket 451 and the attached files.

svil

--~--~-~--~~~---~--~~
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] construct flexible query via sqlalchemy

2007-02-03 Thread dischdennis

Hi,

I would like to build a query dynamically:
I have a list called process_ids that contains the process ids that
should be included in the result set.
so the or_ tuple has to be filled according to the number of items in
list

here an example with 2 items:

where =
or_(PurchaseRequisitionTable.c.processInstance_ID.in_('klora1170507591.97'),
 
PurchaseRequisitionTable.c.processInstance_ID.in_('meier1170549591.67'),)

what is the best way with sqlalchemy to do this? is there also the
possibilty to provide a list or dic directly?

Below my triescheers Dennis



rrr =
get_session().query( self.context.domain_model ).select_by(**d)

if process_ids is not None:
or = []
for p in process_ids:
 
or.append(app_schema.PurchaseRequisitionTable.c.processInstance_ID.in_(p))
t = (i for i in or)
where = or_(t)


rrr = rrr.select(where)

rrr = rrr[int(self.batch_start):int(self.batch_size)]


--~--~-~--~~~---~--~~
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] sqlalchemy lost connection?

2007-02-03 Thread dischdennis

Hi I am using sqlalchemy with zope and when I have the server running
a while ( 6 hours) without interaction, I cannot access any site,
(OperationalError) (2013, 'Lost connection to MySQL server during
query'),
and have to restart the server.


--~--~-~--~~~---~--~~
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: Assign mapper many-to-many with extra columns

2007-02-03 Thread iain duncan

On Fri, 2007-02-02 at 21:41 -0500, Karl Guertin wrote:
 Did my suggestion of dropping 'ordering' off of the article and adding
 an order_by clause to the relation not work?
 
 # article mapper
 assign_mapper( session.context, Article, article_table)
 
 # page mapper with m-to-m relation on articles
 assign_mapper(session.context, Page, page_table, properties = {
articles: relation(Article, secondary=page_article_table,
order_by=page_article_table.c.ordering,
 backref=pages, lazy=False)})
 
 assign_mapper( session.context, Page_Article, page_article_table )
 

No, I got this error message:

InvalidRequestError: Given column 'page_article.ordering', attached to
table 'page_article', failed to locate a corresponding column from table
'article_36c9'


Thanks,
Iain




--~--~-~--~~~---~--~~
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: what is considered circular dep at session.flush() ?

2007-02-03 Thread sdobrev

 yeah im no mathematician but i dont think you can use just part of
 a theory thats designed for flow diagrams with some totally
 different kind of diagram.  
well, relational algebra, or graph theory is just that, and can be 
used for wbatever one finds applicable. diff Application aspects may 
only find better ways to do something, but not change the notions 
there. And add buzzwords, yes.

  i am trying to automaticaly add the relations' post_update, given
  a set of classes and their relations.

 if you make usage of the results of _find_cycles(), its already
 there.  take the edges indicated in the cycle, remove one, then
 sort again.  its an expensive operation, but as the wikipedia
 article states, its an APX Hard problem to find the minimal set
 of edges to be removed.
i know. i'm doing it. 

have a look here 
http://gadfly.sourceforge.net/kjbuckets.html

all cycles in the graph G are given by: G  ~G.tclosure()
and here is topology sort
http://gadfly.cvs.sourceforge.net/gadfly/gadfly/doc/demo/kjbuckets/tsort.py?view=log
http://gadfly.cvs.sourceforge.net/gadfly/gadfly/doc/demo/kjbuckets/tsort2.py?view=log

it's funny, all SQL-servering is just graph algebra, and still one has 
to do one's own graoh calculations to feed the server with proper 
setup or else it will choke...

 noting that, i have
 spent almost no time at all on supporting concrete patterns at this
 point (also, nobody has really complained).
no worries, i've doing now a cut over proper graph, built in similar 
way as the one unitofwork's topology is using, so all should be fine. 
Until u decide to really enter that area. 
Well, i will be notified when this happens :-)
ciao
svil

--~--~-~--~~~---~--~~
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: Assign mapper many-to-many with extra columns

2007-02-03 Thread Karl Guertin

On 2/3/07, iain duncan [EMAIL PROTECTED] wrote:
 InvalidRequestError: Given column 'page_article.ordering', attached to
 table 'page_article', failed to locate a corresponding column from table
 'article_36c9'

I'd think that you're missing the .c. in the middle:

page_article.c.ordering

--~--~-~--~~~---~--~~
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: what is considered circular dep at session.flush() ?

2007-02-03 Thread sdobrev

  noting that, i have
  spent almost no time at all on supporting concrete patterns at
  this point (also, nobody has really complained).

 no worries, i've doing now a cut over proper graph, built in
 similar way as the one unitofwork's topology is using, 
scratch that, instead i propagated a post_update=True, needed in some 
class.mapper.relation.foreignkey, to all of its concrete-inherited 
bases and concrete-inheriting children - this because the relations 
are not inherited for 'concrete' inh, hence i'm re-doing them for 
each child. 
Btw do u want this as ticket to remind u about it one day?

--~--~-~--~~~---~--~~
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: any particular reason for creating unused lists?

2007-02-03 Thread Michael Bayer

On Jan 31, 1:28 pm, svilen [EMAIL PROTECTED] wrote:
 another things i noted:
  - using  value.lower() == value instead of value.islower()

ha

 x = 27
 x.islower()
False
 x.lower() == x
True

breaks a lot of tests too


--~--~-~--~~~---~--~~
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 lost connection?

2007-02-03 Thread iain duncan

On Sat, 2007-03-02 at 20:53 -0500, Mike Bernson wrote:
 Mysql has a timeout idle connection.  You might be running into this. I
 think it defaults to 8 hours It sounds like you are running into the
 idle timeout.
 
 dischdennis wrote:
  Hi I am using sqlalchemy with zope and when I have the server running
  a while ( 6 hours) without interaction, I cannot access any site,
  (OperationalError) (2013, 'Lost connection to MySQL server during
  query'),
  and have to restart the server.

yeah, this is a total freaking pain with MySQL. One of recommended
deployment hacks is to put a cron job on your server to make a pointless
hit on the db server in question once an hour or whatever. Seems
ridiculous but at least it works. I suppose in the case of a web app the
cron job could even be on any old server using wget. 

Iain



--~--~-~--~~~---~--~~
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] Inspect and __init__ of a mapped class

2007-02-03 Thread Patrick Lewis

Hi,

I'm trying to create a  mapped object where I don't know what the
exact constructor arguments of the object might be.  I was trying to
use the inspect module to get the right arguments, but it looks like
the mapper is redefining the original class __init__.  Any thoughts as
to how I might ferret out what the original classes arguments may have
been? I see that the original __init__ it is stored in a local
variable 'oldinit' inside of Mapper._compile_class, but I can't think
of any way to get to that. Any suggestions?


--~--~-~--~~~---~--~~
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: Assign mapper many-to-many with extra columns

2007-02-03 Thread iain duncan

On Sat, 2007-03-02 at 18:44 -0500, Karl Guertin wrote:
 On 2/3/07, iain duncan [EMAIL PROTECTED] wrote:
  InvalidRequestError: Given column 'page_article.ordering', attached to
  table 'page_article', failed to locate a corresponding column from table
  'article_36c9'
 
 I'd think that you're missing the .c. in the middle:
 
 page_article.c.ordering

Nope, just tried again. The mappers are this:

assign_mapper( session.context, Page_Article, page_article_table )
assign_mapper( session.context, Article, article_table ) 

assign_mapper(session.context, Page, page_table, properties = {
   articles: relation(Article, secondary=page_article_table,
   order_by=page_article_table.c.ordering,
backref=pages, lazy=False)})

And the error message is still:
InvalidRequestError: Given column 'page_article.ordering', attached to
table 'page_article', failed to locate a corresponding column from table
'article_61f0'

I am sure that I have dropped all tables, re-run the tg-admin sql create
command, and restarted the shell with fresh imports. 

It looks like association proxy is what I need, so I've been spending
the day reading the SA docs thoroughly. Brain is full!

Thanks for the help
Iain


--~--~-~--~~~---~--~~
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: any particular reason for creating unused lists?

2007-02-03 Thread sdobrev
   - using  value.lower() == value instead of value.islower()

 ha

  x = 27
  x.islower()

 False

  x.lower() == x

 True

 breaks a lot of tests too

okay, forget that. Here an example OrderedSet over set; that seems to 
give a bigger speedup than anything else, and without touching 
anything.
IMO any bigger speedup would require logical changes, e.g. not doing 
certain things at all, caching etc.

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



oset.py.bz2
Description: BZip2 compressed data