[sqlalchemy] Conflicting columns with secondaryjoin

2007-03-16 Thread Mel Collins

 In my project, I have users, who receive messages, which can be
assigned any number of 'tags'. (In the same manner as Gmail's labels)
I've got (amongst others) the following tables:
- UserMessages (userId, messageId, ...)
- UserMessageTags (userId, messageId, tagId)
- UserTags (userId, tagId, ...)

 What I'm trying to do is make all UserTags rows available in the
UserMessages objects. At the moment I have:
orm.mapper (UserMessages, userMessagesTable
,properties={
 'tags': orm.relation(UserTags
,secondary=userMessageTagsTable
,primaryjoin=sql.and_(
 
userMessagesTable.c.userId==userMessageTagsTable.c.userId

,userMessagesTable.c.messageId==userMessageTagsTable.c.messageId
)
,secondaryjoin=sql.and_(
 
userMessageTagsTable.c.userId==userTagsTable.c.userId

,userMessageTagsTable.c.tagId==userTagsTable.c.tagId
)
,lazy=False
,uselist=True
)
}
)

This works find for reading in the data, but when I attempt to remove
an entry from the list:
userMessage.tags.pop()
session.flush()
I get an:
sqlalchemy.exceptions.InvalidRequestError: Column
'userMessageTags.userId' is not available, due to conflicting property
'userId':sqlalchemy.orm.properties.ColumnProperty object at
0xb75ba2ac

 When I changed the primaryjoin and secondaryjoin conditions to only
use messageId and tagId, respectively, it worked as expected. Changing
them to both only use the userId columns caused the same
IvalidRequestError.

 Is this a bug in SA, or in my implementation (which, admittedly, is
usually the case :) )?

 Takk,
 - Mel C


--~--~-~--~~~---~--~~
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: pyodbc and tables with triggers

2007-03-16 Thread Tim Golden

Rick Morrison wrote:
 Sorry, Stephen, I replied too early; your second email arrived before the
 first. A whole day before the first.
 
 So until we get a real cleanup, you're looking to try modules in this order:
 
   ['pyodbc', 'adodbapi', 'pymssql']
 
 Sounds OK to me -- any objections out there?

Looks good to me.

I got slightly confused somewhere through this thread.
When I was putting a test together for the passthrough
patch, I ended up using an Import hook to force a
particular dbapi module to be used programatically
(given that I have all three installed).

Obviously there are variations on that (manually renaming
one etc) but have I missed anything more sophisticated
using SA itself? Didn't look like it to me from the code.

TJG


--~--~-~--~~~---~--~~
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: MS-SQL 2005: unicode inserts fail?

2007-03-16 Thread Paul Johnston

Hi,

This could be a problem with reflection (autoload'ing the table). Try 
defining the table explicitly.

Paul


metaperl wrote:

The following simple program dies (stack trace follows). It is in fact
because of unicode character strings, because the same program works
if you remove the u from in front of the strings.
  



--~--~-~--~~~---~--~~
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] Inconsistent results in session.flush()

2007-03-16 Thread King Simon-NFHD78

Hi,

I'm having a problem where the results of session.flush() vary from one
run to another of my test suite. The unit of work transaction dump is
significantly different from one run to the next, similar to the issue
in ticket 461. I haven't managed to make a test case small enough to
post to the list yet, and I think I need to delve a little further into
the code to find out why it's failing.

(This is with both 0.3.5 and rev2416)

The logs from the UOWTransaction on a failing run and a passing run are
below. As well as the ordering being different, there is at least one
class (ReleaseLine) that doesn't appear in the bad run.

Unfortunately I don't know how to go about debugging this. I think I
need to see exactly what is going on in the dependency sort. Do you have
any suggestions for suitable places to add some extra logging?

This is a failing run:
INFO:sqlalchemy.orm.unitofwork.UOWTransaction.0x..30:Task dump:

 UOWTask(0x184b2b0, Component/component/None) (save/update phase)
   |
   |- UOWTask(0x184bb50, User/user/None) (save/update phase)
   |   |- Save User(0x1851870)
   |   |   |- Process User(0x1851870).branches
   |   |   |- Process User(0x1851870).reviews
   |   |   |- Process User(0x1851870).labels
   |   |   |- Process Branch(0x17ee310).user
   |   |   |- Process Branch(0x184b190).user
   |   |
   |   |- UOWTask(0x184bb70, ChangeOrigin/change_origin/None)
(save/update phase)
   |   |   |   |- Process Branch(0x17ee310).change_origin
   |   |   |   |- Process Branch(0x184b190).change_origin
   |   |   |
   |   |   |- UOWTask(0x184b590, Label/label/None) (save/update phase)
   |   |   |   |
   |   |   |   |- UOWTask(0x184b1b0, Branch/branch/None) (save/update
phase)
   |   |   |   |   |- Save Branch(0x17ee310)
   |   |   |   |   |- Save Branch(0x184b190)
   |   |   |   |   |   |- Process Branch(0x17ee310).review
   |   |   |   |   |   |- Process Branch(0x184b190).review
   |   |   |   |   |
   |   |   |   |   |- UOWTask(0x183f470, Review/review/None)
(save/update phase)

   |   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |   |- UOWTask(0x184bb30,
sqlalchemy.orm.dependency.MapperStub object at 0x0183FDF0)
(save/update phase)
   |   |   |   |   |   |   |- Process Branch(0x17ee310).label
   |   |   |   |   |   |   |- Process Branch(0x184b190).label
   |   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |
   |   |   |   |
   |   |   |   |- UOWTask(0x184bfb0, Counter/counter/None) (save/update
phase)
   |   |   |   |   |- Save Counter(0x184b0f0)
   |   |   |   |   |
   |   |   |   |
   |   |   |   |
   |   |   |
   |   |   |
   |   |
   |   |
   |
   |
   |- UOWTask(0x184bb50, User/user/None) (delete phase)
   |   |
   |   |- UOWTask(0x184bb70, ChangeOrigin/change_origin/None) (delete
phase)
   |   |   |
   |   |   |- UOWTask(0x184b590, Label/label/None) (delete phase)
   |   |   |   |
   |   |   |   |- UOWTask(0x184b1b0, Branch/branch/None) (delete phase)
   |   |   |   |   |
   |   |   |   |   |- UOWTask(0x183f470, Review/review/None) (delete
phase)
   |   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |   |- UOWTask(0x184bb30,
sqlalchemy.orm.dependency.MapperStub object at 0x0183FDF0) (delete
phase)
   |   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |   |
   |   |   |   |
   |   |   |   |
   |   |   |   |- UOWTask(0x184bfb0, Counter/counter/None) (delete
phase)
   |   |   |   |   |
   |   |   |   |
   |   |   |   |
   |   |   |
   |   |   |
   |   |
   |   |
   |
   |

And on a good run looks like this:

INFO:sqlalchemy.orm.unitofwork.UOWTransaction.0x..f0:Task dump:

 UOWTask(0x17f2610, User/user/None) (save/update phase)
   |- Save User(0x17fe9f0)
   |   |- Process User(0x17fe9f0).labels
   |   |- Process Branch(0x17caa10).user
   |   |- Process Branch(0x17f2470).user
   |   |- Process User(0x17fe9f0).reviews
   |   |- Process User(0x17fe9f0).branches
   |
   |- UOWTask(0x17f2a50, ChangeOrigin/change_origin/None) (save/update
phase)
   |   |   |- Process Branch(0x17caa10).change_origin
   |   |   |- Process Branch(0x17f2470).change_origin
   |   |
   |   |- UOWTask(0x17f29f0, Component/component/None) (save/update
phase)
   |   |   |
   |   |   |- UOWTask(0x17f2ad0, ReleaseLine/release_line/None)
(save/update phase)
   |   |   |   |   |- Process Branch(0x17caa10).release_line
   |   |   |   |   |- Process Branch(0x17f2470).release_line
   |   |   |   |   |- Process Counter(0x17fed10).release_line
   |   |   |   |
   |   |   |   |- UOWTask(0x17f2430, Counter/counter/None) (save/update
phase)
   |   |   |   |   |- Save Counter(0x17fed10)
   |   |   |   |   |
   |   |   |   |
   |   |   |   |
   |   |   |   |- UOWTask(0x17f2450, Branch/branch/None) (save/update
phase)
   |   |   |   |   |- Save Branch(0x17caa10)
   |   |   |   |   |- Save Branch(0x17f2470)
   |   |   |   |   |   |- Process Branch(0x17caa10).review
   |   |   |   |   |   

[sqlalchemy] use_labels =30 vs MAX_LABEL_LENGTH

2007-03-16 Thread Jose Soares

Hi Michael,

I see that sql.py uses a limit of 30 characters to create the column 
label when use_labels is set to True.
If name is greater than 30 char long, the label is trunked at position 
24 and is appended a random integer to it.
Since the name created in this way is less useful, I would like to 
sugest you to customize the maxlength of column names.
(PostgreSQL accepts until 63 characters for names, with SQLite you may 
use very, very long names)
  

   def _get_label(self):
if self.__label is None:
if self.table is not None and self.table.named_with_column():
self.__label = self.table.name + _ + self.name
  #if self.table.c.has_key(self.__label) or 
len(self.__label) = 30:
if self.table.c.has_key(self.__label) or 
len(self.__label) = MAX_LABEL_LENGTH:
self.__label = self.__label[0:24] + _ + 
hex(random.randint(0, 65535))[2:]
else:
self.__label = self.name
self.__label = .join([x for x in self.__label if x in 
legal_characters])



--~--~-~--~~~---~--~~
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: error compile

2007-03-16 Thread Jose Soares

Sébastien LELONG ha scritto:
 Seems that SA compiles in a wrong way my query...
 

 Can't what's wrong is happening... subvet appers to be a sub-select, so 
 probably SA made some optimizations. You should print the whole query (print 
 sql) and not the sub-query (as in your code: print subvet) to check if your 
 query is actually compiled the wrong way.

 Seb
   
sql=select([unita_aziendale.c.id],
and_(unita_aziendale.c.id.in_(
  select([azienda_veterinario.c.id_unita_aziendale],
  and_(azienda_veterinario.c.id_veterinario==3,
 azienda_veterinario.c.id_unita_aziendale==unita_aziendale.c.id,
 azienda_veterinario.c.data_inizioNone,
 azienda_veterinario.c.data_fine==None
 ),
 from_obj=[ azienda_veterinario, unita_aziendale],
 ),
)),
)
print sql

SELECT unita_aziendale.id
FROM unita_aziendale
WHERE unita_aziendale.id IN (SELECT 
azienda_veterinario.id_unita_aziendale AS id_unita_aziendale
FROM azienda_veterinario
WHERE azienda_veterinario.id_veterinario = 
%(azienda_veterinario_id_veterinario)s AND 
azienda_veterinario.id_unita_aziendale = unita_aziendale.id AND 
azienda_veterinario.data_inizio IS NOT NULL AND 
azienda_veterinario.data_fine IS NULL)

--
As you can see the from_obj of subselect is wrong, the FROM should be:

FROM azienda_veterinario, unita_aziendale

j



--~--~-~--~~~---~--~~
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: Inconsistent results in session.flush()

2007-03-16 Thread Michael Bayer


On Mar 16, 2007, at 6:59 AM, King Simon-NFHD78 wrote:

 Unfortunately I don't know how to go about debugging this. I think I
 need to see exactly what is going on in the dependency sort. Do you  
 have
 any suggestions for suitable places to add some extra logging?


these issues are often due to bugs in unitofwork.py and are  
unbelievably tough to debug.  which is why youre probably going to  
have to get a test case for me since I really need to nail all of  
these.  if you want to turn on all logging available, youd say  
logger.getLogger('sqlalchemy.orm').setLevel(logging.DEBUG), and youll  
get a whole lot of stuff...after seeing all the logger names you can  
tune out some of the noise with additional setLevel statements.

theres also a monkeypatch thats in the test suite which i use for  
these, it intentionally reverses the order of topological sorts in  
order to flush these out, it looks like:

 from sqlalchemy.orm import unitofwork
 from sqlalchemy import topological
 class RevQueueDepSort(topological.QueueDependencySorter):
 def __init__(self, tuples, allitems):
 self.tuples = list(tuples)
 self.allitems = list(allitems)
 self.tuples.reverse()
 self.allitems.reverse()
 topological.QueueDependencySorter = RevQueueDepSort
 unitofwork.DependencySorter = RevQueueDepSort

but when i get these, it takes me a few hours to wrap my head around  
the issue, and im the one who wrote the code...so dont knock yourself  
out on it...




--~--~-~--~~~---~--~~
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: error compile

2007-03-16 Thread Michael Bayer

put correlate=False in your subquery.

On Mar 16, 2007, at 12:43 PM, Jose Soares wrote:


 Hi,
 Seems that SA compiles in a wrong way my query...

 In [9]: sql=select([UnitaAziendale.c.id])

 In [10]: subvet = select([azienda_veterinario.c.id_unita_aziendale],
: and_(azienda_veterinario.c.id_veterinario==3,
:
 azienda_veterinario.c.id_unita_aziendale==UnitaAziendale.c.id,
: azienda_veterinario.c.data_inizioNone,
: azienda_veterinario.c.data_fine==None
: )
: )

 In [11]:

 In [11]: print subvet
 SELECT azienda_veterinario.id_unita_aziendale
 FROM azienda_veterinario, unita_aziendale
 WHERE azienda_veterinario.id_veterinario =
 %(azienda_veterinario_id_v_5338)s AND
 azienda_veterinario.id_unita_aziendale = unita_aziendale.id AND
 azienda_veterinario.data_inizio IS NOT NULL AND
 azienda_veterinario.data_fine IS NULL

 In [12]: sql.append_whereclause(not_(UnitaAziendale.c.id.in_(subvet)))

 In [13]: print subvet
 (SELECT azienda_veterinario.id_unita_aziendale AS id_unita_aziendale
 FROM azienda_veterinario
 WHERE azienda_veterinario.id_veterinario =
 %(azienda_veterinario_id_v_5338)s AND
 azienda_veterinario.id_unita_aziendale = unita_aziendale.id AND
 azienda_veterinario.data_inizio IS NOT NULL AND
 azienda_veterinario.data_fine IS NULL)

 jo

 


--~--~-~--~~~---~--~~
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: error compile

2007-03-16 Thread Jose Soares

Sébastien LELONG ha scritto:
 As you can see the from_obj of subselect is wrong, the FROM should be:

 FROM azienda_veterinario, unita_aziendale
 

 OK, I see... You probably mean that since your sub-select occurs on two 
 tables, those have to be present in the FROM clause. I've tested this kind on 
 query (select a from A where a in (select b from B where a = b)) and this 
 works ok (MySQL). Your sub-query becomes invalid if taken alone, but the 
 whole keeps correct. What's the error when performing manually the query 
 (using mysql client or the like) ?

 Seb
   
I know it works but the problem is the performance.

this query takes 0m31.073s:

SELECT unita_aziendale.id
FROM unita_aziendale
WHERE unita_aziendale.id IN (SELECT 
azienda_veterinario.id_unita_aziendale AS id_unita_aziendale
FROM azienda_veterinario
WHERE azienda_veterinario.id_veterinario = 3 AND 
azienda_veterinario.id_unita_aziendale = unita_aziendale.id AND 
azienda_veterinario.data_inizio IS NOT NULL AND 
azienda_veterinario.data_fine IS NULL)

this one takes 0m0.686s

SELECT unita_aziendale.id
FROM unita_aziendale
WHERE unita_aziendale.id IN (SELECT 
azienda_veterinario.id_unita_aziendale AS id_unita_aziendale
FROM azienda_veterinario, unita_aziendale
WHERE azienda_veterinario.id_veterinario = 3 AND 
azienda_veterinario.id_unita_aziendale = unita_aziendale.id AND 
azienda_veterinario.data_inizio IS NOT NULL AND 
azienda_veterinario.data_fine IS NULL)

jo



--~--~-~--~~~---~--~~
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: pyodbc and tables with triggers

2007-03-16 Thread Rick Morrison
I don't think you missed anything; that more sophisticated approach is
exactly what we're discussing. Seeing as how you have all three modules
installed and switch between them, you probably have your own ideas about
how it should work. Please pick up the discussion on ticket #480 and give us
your input.

Rick





 Rick Morrison wrote:
  Sorry, Stephen, I replied too early; your second email arrived before
 the
  first. A whole day before the first.
 
  So until we get a real cleanup, you're looking to try modules in this
 order:
 
['pyodbc', 'adodbapi', 'pymssql']
 
  Sounds OK to me -- any objections out there?

 Looks good to me.

 I got slightly confused somewhere through this thread.
 When I was putting a test together for the passthrough
 patch, I ended up using an Import hook to force a
 particular dbapi module to be used programatically
 (given that I have all three installed).

 Obviously there are variations on that (manually renaming
 one etc) but have I missed anything more sophisticated
 using SA itself? Didn't look like it to me from the code.

 TJG


 


--~--~-~--~~~---~--~~
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: Conflicting columns with secondaryjoin

2007-03-16 Thread Michael Bayer

the error youre getting typically occurs when theres more than one  
instance of a userMessageTags.c.userId Column instance.   how there  
might be more than one of the same Column instance can sometimes  
happen when using table reflection and things get confused...although  
I was pretty sure I had fixed all the issues with that.

so i would ask that you are on the latest version of SA (0.3.5), and  
also let me know if youre using autoload=True to get your tables,  
as well as any other tricks you might be doing with Table/MetaData,  
and otherwise try to send me a reproducing test case.  The joins you  
are using should be valid, and i would suspect they are not the  
problem, but are just leading to what the problem actually is;  I  
made a test program on this end using a many-to-many table with four  
columns and it works.


On Mar 16, 2007, at 4:12 AM, Mel Collins wrote:


  In my project, I have users, who receive messages, which can be
 assigned any number of 'tags'. (In the same manner as Gmail's labels)
 I've got (amongst others) the following tables:
 - UserMessages (userId, messageId, ...)
 - UserMessageTags (userId, messageId, tagId)
 - UserTags (userId, tagId, ...)

  What I'm trying to do is make all UserTags rows available in the
 UserMessages objects. At the moment I have:
 orm.mapper (UserMessages, userMessagesTable
   ,properties={
'tags': orm.relation(UserTags
   ,secondary=userMessageTagsTable
   ,primaryjoin=sql.and_(

 userMessagesTable.c.userId==userMessageTagsTable.c.userId
   
 ,userMessagesTable.c.messageId==userMessageTagsTable.c.message 
 Id
   )
   ,secondaryjoin=sql.and_(

 userMessageTagsTable.c.userId==userTagsTable.c.userId
   
 ,userMessageTagsTable.c.tagId==userTagsTable.c.tagId
   )
   ,lazy=False
   ,uselist=True
   )
   }
   )

 This works find for reading in the data, but when I attempt to remove
 an entry from the list:
 userMessage.tags.pop()
 session.flush()
 I get an:
 sqlalchemy.exceptions.InvalidRequestError: Column
 'userMessageTags.userId' is not available, due to conflicting property
 'userId':sqlalchemy.orm.properties.ColumnProperty object at
 0xb75ba2ac

  When I changed the primaryjoin and secondaryjoin conditions to only
 use messageId and tagId, respectively, it worked as expected. Changing
 them to both only use the userId columns caused the same
 IvalidRequestError.

  Is this a bug in SA, or in my implementation (which, admittedly, is
 usually the case :) )?

  Takk,
  - Mel C


 


--~--~-~--~~~---~--~~
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: Inconsistent results in session.flush()

2007-03-16 Thread Michael Bayer

I can actually read a fair degree from these dumps, i need mostly to  
know what the actual dependencies are (i.e. which classes are  
dependent on what, whats the error).  also when you do the full debug  
echoing the UOW should illustrate a series of dependency tuples  
which will show what pairs of classes the UOW perceives as  
dependent on each other.

On Mar 16, 2007, at 6:59 AM, King Simon-NFHD78 wrote:


 Hi,

 I'm having a problem where the results of session.flush() vary from  
 one
 run to another of my test suite. The unit of work transaction dump is
 significantly different from one run to the next, similar to the issue
 in ticket 461. I haven't managed to make a test case small enough to
 post to the list yet, and I think I need to delve a little further  
 into
 the code to find out why it's failing.

 (This is with both 0.3.5 and rev2416)

 The logs from the UOWTransaction on a failing run and a passing run  
 are
 below. As well as the ordering being different, there is at least one
 class (ReleaseLine) that doesn't appear in the bad run.

 Unfortunately I don't know how to go about debugging this. I think I
 need to see exactly what is going on in the dependency sort. Do you  
 have
 any suggestions for suitable places to add some extra logging?

 This is a failing run:
 INFO:sqlalchemy.orm.unitofwork.UOWTransaction.0x..30:Task dump:

  UOWTask(0x184b2b0, Component/component/None) (save/update phase)
|
|- UOWTask(0x184bb50, User/user/None) (save/update phase)
|   |- Save User(0x1851870)
|   |   |- Process User(0x1851870).branches
|   |   |- Process User(0x1851870).reviews
|   |   |- Process User(0x1851870).labels
|   |   |- Process Branch(0x17ee310).user
|   |   |- Process Branch(0x184b190).user
|   |
|   |- UOWTask(0x184bb70, ChangeOrigin/change_origin/None)
 (save/update phase)
|   |   |   |- Process Branch(0x17ee310).change_origin
|   |   |   |- Process Branch(0x184b190).change_origin
|   |   |
|   |   |- UOWTask(0x184b590, Label/label/None) (save/update phase)
|   |   |   |
|   |   |   |- UOWTask(0x184b1b0, Branch/branch/None) (save/update
 phase)
|   |   |   |   |- Save Branch(0x17ee310)
|   |   |   |   |- Save Branch(0x184b190)
|   |   |   |   |   |- Process Branch(0x17ee310).review
|   |   |   |   |   |- Process Branch(0x184b190).review
|   |   |   |   |
|   |   |   |   |- UOWTask(0x183f470, Review/review/None)
 (save/update phase)

|   |   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |- UOWTask(0x184bb30,
 sqlalchemy.orm.dependency.MapperStub object at 0x0183FDF0)
 (save/update phase)
|   |   |   |   |   |   |- Process Branch(0x17ee310).label
|   |   |   |   |   |   |- Process Branch(0x184b190).label
|   |   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |
|   |   |   |
|   |   |   |- UOWTask(0x184bfb0, Counter/counter/None) (save/ 
 update
 phase)
|   |   |   |   |- Save Counter(0x184b0f0)
|   |   |   |   |
|   |   |   |
|   |   |   |
|   |   |
|   |   |
|   |
|   |
|
|
|- UOWTask(0x184bb50, User/user/None) (delete phase)
|   |
|   |- UOWTask(0x184bb70, ChangeOrigin/change_origin/None) (delete
 phase)
|   |   |
|   |   |- UOWTask(0x184b590, Label/label/None) (delete phase)
|   |   |   |
|   |   |   |- UOWTask(0x184b1b0, Branch/branch/None) (delete  
 phase)
|   |   |   |   |
|   |   |   |   |- UOWTask(0x183f470, Review/review/None) (delete
 phase)
|   |   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |- UOWTask(0x184bb30,
 sqlalchemy.orm.dependency.MapperStub object at 0x0183FDF0) (delete
 phase)
|   |   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |
|   |   |   |
|   |   |   |- UOWTask(0x184bfb0, Counter/counter/None) (delete
 phase)
|   |   |   |   |
|   |   |   |
|   |   |   |
|   |   |
|   |   |
|   |
|   |
|
|

 And on a good run looks like this:

 INFO:sqlalchemy.orm.unitofwork.UOWTransaction.0x..f0:Task dump:

  UOWTask(0x17f2610, User/user/None) (save/update phase)
|- Save User(0x17fe9f0)
|   |- Process User(0x17fe9f0).labels
|   |- Process Branch(0x17caa10).user
|   |- Process Branch(0x17f2470).user
|   |- Process User(0x17fe9f0).reviews
|   |- Process User(0x17fe9f0).branches
|
|- UOWTask(0x17f2a50, ChangeOrigin/change_origin/None) (save/update
 phase)
|   |   |- Process Branch(0x17caa10).change_origin
|   |   |- Process Branch(0x17f2470).change_origin
|   |
|   |- UOWTask(0x17f29f0, Component/component/None) (save/update
 phase)
|   |   |
|   |   |- UOWTask(0x17f2ad0, ReleaseLine/release_line/None)
 (save/update phase)
|   |   |   |   |- Process Branch(0x17caa10).release_line
|   |   |   |   

[sqlalchemy] Re: cascading question

2007-03-16 Thread Alexandre CONRAD

Humm, this doesn't help as if a site is deleted, it deletes the options 
that where related to that option.

I want to be able to:
- delete an option without deleting a site
- delete a site without deleting an option

just delete (clean up) the related rows inside the weak 
options_has_sites table.

I just can't figure it out...


Michael Bayer wrote:

 
 youd need to add some delete cascades to your relationship, maybe  
 on just the backref (using the backref() function), e.g.
 
 option_mapper = assign_mapper(ctx, Option, option_table,
   properties={
   'sites':relation(Site, backref=backref(options,  
 cascade=save-update, delete),
 secondary=options_has_sites, cascade=save-update),
   },
   order_by=option_table.c.name,
 )
 
 
 
 On Mar 16, 2007, at 10:38 AM, Alexandre CONRAD wrote:
 
 
Hello,

I have a many-to-many relation between an option table and a site  
table.

Deleting an option correctly deletes the related rows in
options_has_sites table.

But when I delete a site, I have some orphan rows in the
options_has_sites table. How can I avoid this ?


# SITE TABLE ---
site_table = Table('sites', meta,
 Column('id', Integer, primary_key=True),
 Column('name', Unicode(20), nullable=False, unique=True),
)

class Site(object):
 pass

site_mapper = assign_mapper(ctx, Site, site_table,
 order_by=site_table.c.name,
)


# OPTION TABLE 
option_table = Table('options', meta,
 Column('id', Integer, primary_key=True),
 Column('name', Unicode(20), unique=True, nullable=False),
)

options_has_sites = Table('sites_has_options', meta,
 Column('id_site', None, ForeignKey('sites.id'),  
primary_key=True),
 Column('id_option', None, ForeignKey('options.id'),  
primary_key=True),
)

class Option(object):
 pass

option_mapper = assign_mapper(ctx, Option, option_table,
 properties={
 'sites':relation(Site, backref=options,
secondary=options_has_sites, cascade=save-update),
 },
 order_by=option_table.c.name,
)


Should I play with backref() ?

Regards,
-- 
Alexandre CONRAD



 
 
  
 
 
 ---
 Texte inséré par Platinum 2007:
 
  S'il s'agit d'un mail indésirable (SPAM), cliquez sur le lien suivant pour 
 le reclasser : http://127.0.0.1:6083/Panda?ID=pav_31913SPAM=true
 ---
 
 

-- 
Alexandre CONRAD - TLV FRANCE
Research  Development


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

2007-03-16 Thread Michael Bayer

the rows in the M2M table should be deleted automatically.it  
*might* require that your instances are present in the session but  
its not supposed to.  can you make me a short test case for this  
one ?  its not the first time ive heard about it.

technically you can just put ON DELETE CASCADE on the tables too but  
id like to fix this issue.


On Mar 16, 2007, at 12:19 PM, Alexandre CONRAD wrote:


 Humm, this doesn't help as if a site is deleted, it deletes the  
 options
 that where related to that option.

 I want to be able to:
 - delete an option without deleting a site
 - delete a site without deleting an option

 just delete (clean up) the related rows inside the weak
 options_has_sites table.

 I just can't figure it out...


 Michael Bayer wrote:


 youd need to add some delete cascades to your relationship, maybe
 on just the backref (using the backref() function), e.g.

 option_mapper = assign_mapper(ctx, Option, option_table,
   properties={
   'sites':relation(Site, backref=backref(options,
 cascade=save-update, delete),
 secondary=options_has_sites, cascade=save-update),
   },
   order_by=option_table.c.name,
 )



 On Mar 16, 2007, at 10:38 AM, Alexandre CONRAD wrote:


 Hello,

 I have a many-to-many relation between an option table and a site
 table.

 Deleting an option correctly deletes the related rows in
 options_has_sites table.

 But when I delete a site, I have some orphan rows in the
 options_has_sites table. How can I avoid this ?


 # SITE TABLE ---
 site_table = Table('sites', meta,
 Column('id', Integer, primary_key=True),
 Column('name', Unicode(20), nullable=False, unique=True),
 )

 class Site(object):
 pass

 site_mapper = assign_mapper(ctx, Site, site_table,
 order_by=site_table.c.name,
 )


 # OPTION TABLE 
 option_table = Table('options', meta,
 Column('id', Integer, primary_key=True),
 Column('name', Unicode(20), unique=True, nullable=False),
 )

 options_has_sites = Table('sites_has_options', meta,
 Column('id_site', None, ForeignKey('sites.id'),
 primary_key=True),
 Column('id_option', None, ForeignKey('options.id'),
 primary_key=True),
 )

 class Option(object):
 pass

 option_mapper = assign_mapper(ctx, Option, option_table,
 properties={
 'sites':relation(Site, backref=options,
 secondary=options_has_sites, cascade=save-update),
 },
 order_by=option_table.c.name,
 )


 Should I play with backref() ?

 Regards,
 -- 
 Alexandre CONRAD








 - 
 --
 Texte inséré par Platinum 2007:

  S'il s'agit d'un mail indésirable (SPAM), cliquez sur le lien  
 suivant pour le reclasser : http://127.0.0.1:6083/Panda? 
 ID=pav_31913SPAM=true
 - 
 --



 -- 
 Alexandre CONRAD - TLV FRANCE
 Research  Development


 


--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread Michael Bayer

all tests pass on Mac OSX with the latest sqlite (as well as  
postgres, mysql).

solaris, not so sure, ill have  a look later.

On Mar 16, 2007, at 1:19 PM, [EMAIL PROTECTED] wrote:



 Michael OK this was something small, the alltests.py scripts  
 needed
 Michael to call testbase's main() function and not its runTests()
 Michael method, so that the exit code is propigated.  rev 2414.

 skip Excellent.  Trying a test run now...

 The good news is the test failures are now properly reported.  The  
 bad news
 is there are test failures.  I'm going to try and get things set up  
 to test
 on the Solaris systems at work, but it would help if people could  
 take a
 peek at the test logs:

 http://www.python.org/dev/buildbot/community/all/g5%20OSX% 
 20trunk/builds/37/step-SQLAlchemy/0
 http://www.python.org/dev/buildbot/community/all/g5%20OSX%202.5/ 
 builds/16/step-SQLAlchemy/0

 and let me know if any of those are expected.  It would also help  
 if someone
 using SA on Mac OSX could run the tests to see what (if anything)  
 fails.

 Thx,

 -- 
 Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
 The hippies and the hipsters did some great stuff in the sixties,
 but the geeks pulled their weight too. -- Billy Bragg

 


--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread Michael Bayer

I just ran my python 2.5 install (its a framework install) on OSX  
against the test suite on r2418, which uses the built-in sqlite3, and  
i got all tests passed.

On Mar 16, 2007, at 1:19 PM, [EMAIL PROTECTED] wrote:



 Michael OK this was something small, the alltests.py scripts  
 needed
 Michael to call testbase's main() function and not its runTests()
 Michael method, so that the exit code is propigated.  rev 2414.

 skip Excellent.  Trying a test run now...

 The good news is the test failures are now properly reported.  The  
 bad news
 is there are test failures.  I'm going to try and get things set up  
 to test
 on the Solaris systems at work, but it would help if people could  
 take a
 peek at the test logs:

 http://www.python.org/dev/buildbot/community/all/g5%20OSX% 
 20trunk/builds/37/step-SQLAlchemy/0
 http://www.python.org/dev/buildbot/community/all/g5%20OSX%202.5/ 
 builds/16/step-SQLAlchemy/0

 and let me know if any of those are expected.  It would also help  
 if someone
 using SA on Mac OSX could run the tests to see what (if anything)  
 fails.

 Thx,

 -- 
 Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
 The hippies and the hipsters did some great stuff in the sixties,
 but the geeks pulled their weight too. -- Billy Bragg

 


--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread Michael Bayer

geez, what version of sqlite / pysqlite / python is running there ?   
tons of those errors ive never seen before.


On Mar 16, 2007, at 1:19 PM, [EMAIL PROTECTED] wrote:



 Michael OK this was something small, the alltests.py scripts  
 needed
 Michael to call testbase's main() function and not its runTests()
 Michael method, so that the exit code is propigated.  rev 2414.

 skip Excellent.  Trying a test run now...

 The good news is the test failures are now properly reported.  The  
 bad news
 is there are test failures.  I'm going to try and get things set up  
 to test
 on the Solaris systems at work, but it would help if people could  
 take a
 peek at the test logs:

 http://www.python.org/dev/buildbot/community/all/g5%20OSX% 
 20trunk/builds/37/step-SQLAlchemy/0
 http://www.python.org/dev/buildbot/community/all/g5%20OSX%202.5/ 
 builds/16/step-SQLAlchemy/0

 and let me know if any of those are expected.  It would also help  
 if someone
 using SA on Mac OSX could run the tests to see what (if anything)  
 fails.

 Thx,

 -- 
 Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
 The hippies and the hipsters did some great stuff in the sixties,
 but the geeks pulled their weight too. -- Billy Bragg

 


--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread Michael Bayer

ah, in fact one failure youre having, the testcast failure, is  
indicative of running against a very old sqlite.

FAIL: testcast (sql.select.SelectTest)
--
Traceback (most recent call last):
   File /private/tmp/sqlalchemy/test/sql/select.py, line 737, in  
testcast
 check_results(sqlite.dialect(), ['NUMERIC(10, 2)', 'NUMERIC(12,  
9)', 'DATE', 'TEXT', 'VARCHAR(20)'], '?')
   File /private/tmp/sqlalchemy/test/sql/select.py, line 723, in  
check_results
 self.assertEqual(str(cast(tbl.c.v1, Numeric).compile 
(dialect=dialect)), 'CAST(casttest.v1 AS %s)' %expected_results[0])
AssertionError: 'casttest.v1' != 'CAST(casttest.v1 AS NUMERIC(10, 2))'

the CAST isnt happening for the sqlite dialect.  this only occurs if  
this logic takes place:

 self.supports_cast = (sqlite is not None and vers 
(sqlite.sqlite_version) = vers(3.2.3))

if youre running py2.5 it should be using the sqlite3 thats included,  
which on my install is 3.3.5.  otherwise you should run 3.3.13  
since there was an order by bug in 3.3.12 and a few previous versions.

On Mar 16, 2007, at 1:19 PM, [EMAIL PROTECTED] wrote:



 Michael OK this was something small, the alltests.py scripts  
 needed
 Michael to call testbase's main() function and not its runTests()
 Michael method, so that the exit code is propigated.  rev 2414.

 skip Excellent.  Trying a test run now...

 The good news is the test failures are now properly reported.  The  
 bad news
 is there are test failures.  I'm going to try and get things set up  
 to test
 on the Solaris systems at work, but it would help if people could  
 take a
 peek at the test logs:

 http://www.python.org/dev/buildbot/community/all/g5%20OSX% 
 20trunk/builds/37/step-SQLAlchemy/0
 http://www.python.org/dev/buildbot/community/all/g5%20OSX%202.5/ 
 builds/16/step-SQLAlchemy/0

 and let me know if any of those are expected.  It would also help  
 if someone
 using SA on Mac OSX could run the tests to see what (if anything)  
 fails.

 Thx,

 -- 
 Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
 The hippies and the hipsters did some great stuff in the sixties,
 but the geeks pulled their weight too. -- Billy Bragg

 


--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread skip . montanaro


Michael all tests pass on Mac OSX with the latest sqlite (as well as
Michael postgres, mysql).

Hmmm...  Then I wonder what's different about the buildbot setup and a
normal interactive run.

Michael solaris, not so sure, ill have  a look later.

There's no particular need.  I was just hoping to get a different data point
to compare my buildbot results with.  You provided that with your Mac OSX
results.

Skip

--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread skip . montanaro


Michael geez, what version of sqlite / pysqlite / python is running
Michael there ?  tons of those errors ive never seen before.

That will have to wait for me to get home.  Probably not until tomorrow at
the earliest.  I'll let you know what I figure out.  Perhaps I can tweak the
buildslave script to emit the relevant version information.

Skip

--~--~-~--~~~---~--~~
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: Inconsistent results in session.flush()

2007-03-16 Thread King Simon-NFHD78
I've just run the attached script about thirty times, and it succeeded 5
times and failed the rest. I've cut out a lot of unnecessary stuff, but
it's still a bit long I'm afraid. I'll cut it down some more, but since
you seemed so eager to see it ;-) I thought I'd send it along as is.

On a bad run, the dependency tuples look like this:

DEBUG:sqlalchemy.orm.unitofwork.UOWTransaction.0x..50:Dependency sort:
Mapper|User|user
  Mapper|Component|component
Mapper|ChangeOrigin|change_origin
  Mapper|Label|label (cycles: [Mapper|Label|label,
Mapper|ReleaseLine|release_line])
Mapper|Counter|counter
Mapper|Branch|branch
  sqlalchemy.orm.dependency.MapperStub object at 0x00D59590

And on a good run they look like this:

DEBUG:sqlalchemy.orm.unitofwork.UOWTransaction.0x..10:Dependency sort:
Mapper|User|user
  Mapper|Component|component
Mapper|ChangeOrigin|change_origin
  Mapper|ReleaseLine|release_line (cycles:
[Mapper|ReleaseLine|release_line,  Mapper|Label|label])
Mapper|Counter|counter
Mapper|Branch|branch
  sqlalchemy.orm.dependency.MapperStub object at 0x00D59670

Thanks a lot for looking at this,

Simon

Michael Bayer wrote:
 
 I can actually read a fair degree from these dumps, i need 
 mostly to know what the actual dependencies are (i.e. which 
 classes are dependent on what, whats the error).  also when 
 you do the full debug echoing the UOW should illustrate a 
 series of dependency tuples  
 which will show what pairs of classes the UOW perceives as 
 dependent on each other.
 
 On Mar 16, 2007, at 6:59 AM, King Simon-NFHD78 wrote:
 
 
  Hi,
 
  I'm having a problem where the results of session.flush() vary from 
  one run to another of my test suite. The unit of work 
 transaction dump 
  is significantly different from one run to the next, similar to the 
  issue in ticket 461. I haven't managed to make a test case small 
  enough to post to the list yet, and I think I need to delve 
 a little 
  further into the code to find out why it's failing.
 
  (This is with both 0.3.5 and rev2416)
 
  The logs from the UOWTransaction on a failing run and a passing run 
  are below. As well as the ordering being different, there 
 is at least 
  one class (ReleaseLine) that doesn't appear in the bad run.
 
  Unfortunately I don't know how to go about debugging this. 
 I think I 
  need to see exactly what is going on in the dependency sort. Do you 
  have any suggestions for suitable places to add some extra logging?
 
  This is a failing run:
  INFO:sqlalchemy.orm.unitofwork.UOWTransaction.0x..30:Task dump:
 
   UOWTask(0x184b2b0, Component/component/None) (save/update phase)
 |
 |- UOWTask(0x184bb50, User/user/None) (save/update phase)
 |   |- Save User(0x1851870)
 |   |   |- Process User(0x1851870).branches
 |   |   |- Process User(0x1851870).reviews
 |   |   |- Process User(0x1851870).labels
 |   |   |- Process Branch(0x17ee310).user
 |   |   |- Process Branch(0x184b190).user
 |   |
 |   |- UOWTask(0x184bb70, ChangeOrigin/change_origin/None)
  (save/update phase)
 |   |   |   |- Process Branch(0x17ee310).change_origin
 |   |   |   |- Process Branch(0x184b190).change_origin
 |   |   |
 |   |   |- UOWTask(0x184b590, Label/label/None) 
 (save/update phase)
 |   |   |   |
 |   |   |   |- UOWTask(0x184b1b0, Branch/branch/None) 
 (save/update
  phase)
 |   |   |   |   |- Save Branch(0x17ee310)
 |   |   |   |   |- Save Branch(0x184b190)
 |   |   |   |   |   |- Process Branch(0x17ee310).review
 |   |   |   |   |   |- Process Branch(0x184b190).review
 |   |   |   |   |
 |   |   |   |   |- UOWTask(0x183f470, Review/review/None)
  (save/update phase)
 
 |   |   |   |   |   |
 |   |   |   |   |
 |   |   |   |   |
 |   |   |   |   |- UOWTask(0x184bb30,
  sqlalchemy.orm.dependency.MapperStub object at 0x0183FDF0) 
  (save/update phase)
 |   |   |   |   |   |   |- Process Branch(0x17ee310).label
 |   |   |   |   |   |   |- Process Branch(0x184b190).label
 |   |   |   |   |   |
 |   |   |   |   |
 |   |   |   |   |
 |   |   |   |
 |   |   |   |
 |   |   |   |- UOWTask(0x184bfb0, Counter/counter/None) (save/ 
  update
  phase)
 |   |   |   |   |- Save Counter(0x184b0f0)
 |   |   |   |   |
 |   |   |   |
 |   |   |   |
 |   |   |
 |   |   |
 |   |
 |   |
 |
 |
 |- UOWTask(0x184bb50, User/user/None) (delete phase)
 |   |
 |   |- UOWTask(0x184bb70, 
 ChangeOrigin/change_origin/None) (delete
  phase)
 |   |   |
 |   |   |- UOWTask(0x184b590, Label/label/None) (delete phase)
 |   |   |   |
 |   |   |   |- UOWTask(0x184b1b0, Branch/branch/None) (delete  
  phase)
 |   |   |   |   |
 |   |   |   |   |- UOWTask(0x183f470, Review/review/None) (delete
  phase)
 |   |   |   |   |   |
 |   |   |   |   |
 |   |   |   |   

[sqlalchemy] Use pyPgSQL module with SA?

2007-03-16 Thread lwkinca

Hi-
My apologies if this has been asked and answered, but I was unable to
find any reference.  The SA documentation says it's possible to
pyPgSQL instead of psycopg2 but I can't make it work.  Basically,
here's what I'm trying:

from sqlalchemy import *
from pyPgSQL import libpq

def myConn():
return libpq.PQconnectdb(host=localhost port=5432 dbname=...
user=... password=...)

db=create_engine('postgres://', creator=myConn)

This results in sqlalchemy.exceptions.InvalidRequestError: Cant get
DBAPI module for dialect 'sqlalchemy.databases.postgres.PGDialect
object

Any idea what dumb mistake I'm making?  Thanks.

Larry


--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread skip . montanaro


Michael ah, in fact one failure youre having, the testcast failure,
Michael is indicative of running against a very old sqlite.

Can you tell me what version I'm using other than very old?  Here's what I
see:

$ otool -L lib-dynload/_sqlite3.so
lib-dynload/_sqlite3.so:
/usr/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current 
version 9.6.0)
/usr/lib/libmx.A.dylib (compatibility version 1.0.0, current 
version 93.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 88.1.8)

and the stuff in /usr/lib looks fairly new:

$ ls -Ll libsqlite3.*
-rwxr-xr-x   1 root  wheel  284508 Mar 14 20:04 libsqlite3.0.8.6.dylib
-rwxr-xr-x   1 root  wheel  284508 Mar 14 20:04 libsqlite3.0.dylib
-rwxr-xr-x   1 root  wheel  284508 Mar 14 20:04 libsqlite3.dylib

I suppose it's possible that I'm picking up another version.  I have an old
version of Darwin Ports on the machine and Python comes with sqlite of some
version.

Skip

--~--~-~--~~~---~--~~
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 test suite - no success/failure exit code

2007-03-16 Thread Michael Bayer

go into python and type:

from pysqlite2 import dbapi2
dbapi2.sqlite_version


On Mar 16, 2007, at 3:23 PM, [EMAIL PROTECTED] wrote:



 Michael ah, in fact one failure youre having, the testcast  
 failure,
 Michael is indicative of running against a very old sqlite.

 Can you tell me what version I'm using other than very old?   
 Here's what I
 see:

 $ otool -L lib-dynload/_sqlite3.so
 lib-dynload/_sqlite3.so:
 /usr/lib/libsqlite3.0.dylib (compatibility version  
 9.0.0, current version 9.6.0)
 /usr/lib/libmx.A.dylib (compatibility version 1.0.0,  
 current version 93.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version  
 1.0.0, current version 88.1.8)

 and the stuff in /usr/lib looks fairly new:

 $ ls -Ll libsqlite3.*
 -rwxr-xr-x   1 root  wheel  284508 Mar 14 20:04  
 libsqlite3.0.8.6.dylib
 -rwxr-xr-x   1 root  wheel  284508 Mar 14 20:04 libsqlite3.0.dylib
 -rwxr-xr-x   1 root  wheel  284508 Mar 14 20:04 libsqlite3.dylib

 I suppose it's possible that I'm picking up another version.  I  
 have an old
 version of Darwin Ports on the machine and Python comes with sqlite  
 of some
 version.

 Skip

 


--~--~-~--~~~---~--~~
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: Inconsistent results in session.flush()

2007-03-16 Thread Michael Bayer

oh, this is easy.  you have a circular insert relationship between  
label and release_line, which you can see in the sort there (the  
cycles:) as well as evidenced by the fact that you have a  
use_alter needed in order to create the foreign keys on those two  
tables.  add post_update=True to one of the relationships which  
will break that particular cycle by using a second UPDATE statement,  
and youre in.

On Mar 16, 2007, at 1:58 PM, King Simon-NFHD78 wrote:

 I've just run the attached script about thirty times, and it  
 succeeded 5
 times and failed the rest. I've cut out a lot of unnecessary stuff,  
 but
 it's still a bit long I'm afraid. I'll cut it down some more, but  
 since
 you seemed so eager to see it ;-) I thought I'd send it along as is.

 On a bad run, the dependency tuples look like this:

 DEBUG:sqlalchemy.orm.unitofwork.UOWTransaction.0x..50:Dependency sort:
 Mapper|User|user
   Mapper|Component|component
 Mapper|ChangeOrigin|change_origin
   Mapper|Label|label (cycles: [Mapper|Label|label,
 Mapper|ReleaseLine|release_line])
 Mapper|Counter|counter
 Mapper|Branch|branch
   sqlalchemy.orm.dependency.MapperStub object at 0x00D59590

 And on a good run they look like this:

 DEBUG:sqlalchemy.orm.unitofwork.UOWTransaction.0x..10:Dependency sort:
 Mapper|User|user
   Mapper|Component|component
 Mapper|ChangeOrigin|change_origin
   Mapper|ReleaseLine|release_line (cycles:
 [Mapper|ReleaseLine|release_line,  Mapper|Label|label])
 Mapper|Counter|counter
 Mapper|Branch|branch
   sqlalchemy.orm.dependency.MapperStub object at 0x00D59670

 Thanks a lot for looking at this,

 Simon

 Michael Bayer wrote:

 I can actually read a fair degree from these dumps, i need
 mostly to know what the actual dependencies are (i.e. which
 classes are dependent on what, whats the error).  also when
 you do the full debug echoing the UOW should illustrate a
 series of dependency tuples
 which will show what pairs of classes the UOW perceives as
 dependent on each other.

 On Mar 16, 2007, at 6:59 AM, King Simon-NFHD78 wrote:


 Hi,

 I'm having a problem where the results of session.flush() vary from
 one run to another of my test suite. The unit of work
 transaction dump
 is significantly different from one run to the next, similar to the
 issue in ticket 461. I haven't managed to make a test case small
 enough to post to the list yet, and I think I need to delve
 a little
 further into the code to find out why it's failing.

 (This is with both 0.3.5 and rev2416)

 The logs from the UOWTransaction on a failing run and a passing run
 are below. As well as the ordering being different, there
 is at least
 one class (ReleaseLine) that doesn't appear in the bad run.

 Unfortunately I don't know how to go about debugging this.
 I think I
 need to see exactly what is going on in the dependency sort. Do you
 have any suggestions for suitable places to add some extra logging?

 This is a failing run:
 INFO:sqlalchemy.orm.unitofwork.UOWTransaction.0x..30:Task dump:

  UOWTask(0x184b2b0, Component/component/None) (save/update phase)
|
|- UOWTask(0x184bb50, User/user/None) (save/update phase)
|   |- Save User(0x1851870)
|   |   |- Process User(0x1851870).branches
|   |   |- Process User(0x1851870).reviews
|   |   |- Process User(0x1851870).labels
|   |   |- Process Branch(0x17ee310).user
|   |   |- Process Branch(0x184b190).user
|   |
|   |- UOWTask(0x184bb70, ChangeOrigin/change_origin/None)
 (save/update phase)
|   |   |   |- Process Branch(0x17ee310).change_origin
|   |   |   |- Process Branch(0x184b190).change_origin
|   |   |
|   |   |- UOWTask(0x184b590, Label/label/None)
 (save/update phase)
|   |   |   |
|   |   |   |- UOWTask(0x184b1b0, Branch/branch/None)
 (save/update
 phase)
|   |   |   |   |- Save Branch(0x17ee310)
|   |   |   |   |- Save Branch(0x184b190)
|   |   |   |   |   |- Process Branch(0x17ee310).review
|   |   |   |   |   |- Process Branch(0x184b190).review
|   |   |   |   |
|   |   |   |   |- UOWTask(0x183f470, Review/review/None)
 (save/update phase)

|   |   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |- UOWTask(0x184bb30,
 sqlalchemy.orm.dependency.MapperStub object at 0x0183FDF0)
 (save/update phase)
|   |   |   |   |   |   |- Process Branch(0x17ee310).label
|   |   |   |   |   |   |- Process Branch(0x184b190).label
|   |   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |
|   |   |   |
|   |   |   |- UOWTask(0x184bfb0, Counter/counter/None) (save/
 update
 phase)
|   |   |   |   |- Save Counter(0x184b0f0)
|   |   |   |   |
|   |   |   |
|   |   |   |
|   |   |
|   |   |
|   |
|   |
|
|
|- UOWTask(0x184bb50, User/user/None) (delete phase)
|   |
|   |- UOWTask(0x184bb70,