[sqlalchemy] Re: IntegrityError during query?

2007-10-02 Thread [EMAIL PROTECTED]

Hi Michael, sorry about the lack of information; I wasn't clear on
what you were looking for.

The failing constraint is a customer one for email addresses:

CREATE DOMAIN base.email as TEXT CHECK
(VALUE ~ '[EMAIL PROTECTED](\\.[-\\w]+)*\\.\\w{2,4}$');

Thanks again!
Mark

On Oct 1, 5:46 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Oct 1, 2007, at 2:29 PM, [EMAIL PROTECTED] wrote:





  Hi Michael,

  I'm creating the session by:

Session = sessionmaker(bind = engine,
 autoflush = True,
 transactional = True)
session = Session()

  and I'm not using any threading at all (therefore no thread-local
  storage). The only thing between the commit and the next query is some
  reporting of statistics (using sys.stdout).

  I'm getting a constraint violation IntegrityError.

 unique constraint ? PK constraint ? foreign key constraint ?are
 you doing any explicit INSERT statements of your own independent of
 the session ?

 I cant diagnose the problem any further on this end without an
 explicit example.


--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-02 Thread Michael Bayer


On Oct 2, 2007, at 7:56 AM, [EMAIL PROTECTED] wrote:


 Hi Michael, sorry about the lack of information; I wasn't clear on
 what you were looking for.

 The failing constraint is a customer one for email addresses:

 CREATE DOMAIN base.email as TEXT CHECK
 (VALUE ~ '[EMAIL PROTECTED](\\.[-\\w]+)*\\.\\w{2,4}$');


you'd have to ensure the text youre inserting meets that regular  
expression.




--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-02 Thread Michael Bayer


On Oct 2, 2007, at 7:56 AM, [EMAIL PROTECTED] wrote:


 Hi Michael, sorry about the lack of information; I wasn't clear on
 what you were looking for.

 The failing constraint is a customer one for email addresses:

 CREATE DOMAIN base.email as TEXT CHECK
 (VALUE ~ '[EMAIL PROTECTED](\\.[-\\w]+)*\\.\\w{2,4}$');


oh.  also, you should not save() the object which represents this  
insert (or at least perform any additional queries) until its fields  
are fully assembled.  since you are using autoflush=True, the  
contents of the session will be flushed automatically before every  
query.



--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-01 Thread [EMAIL PROTECTED]

Hi again, I really must be missing something fundamental here as I
cannot seem to solve this problem:

I have a loop that queries one table (without any contraints) and
writes to a second table (with constraints). Here's what the loop
looks like in pseudo-code:

while True:
  1) query old table and create a work list
  2) while items are in the work list:
  2.1) create a new object
  2.2) save
  3) commit

I can wrap the save (2.2) and commit (3) in try/except blocks which
solves the IntegrityError exceptions at that point. The problem is
that I'm getting IntegrityError exceptions in the query section (1)
what seem to be deferred INSERTS from the commit (3).

How can I turn off the deferred inserts?

Mark

On Sep 25, 9:27 am, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hi,  I have a newbie question:

 I'm parsing a log file in order to record login-times but I'm getting
 an IntegrityError on an insert during a query. Does this make sense?
 Even though I'm going a commit at the botton of the loop should I
 expect the INSERT to actually happen during a subsequent query?

 Thanks,
 Mark


--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-01 Thread Michael Bayer


On Oct 1, 2007, at 11:02 AM, [EMAIL PROTECTED] wrote:


 Hi again, I really must be missing something fundamental here as I
 cannot seem to solve this problem:

 I have a loop that queries one table (without any contraints) and
 writes to a second table (with constraints). Here's what the loop
 looks like in pseudo-code:

 while True:
   1) query old table and create a work list
   2) while items are in the work list:
   2.1) create a new object
   2.2) save
   3) commit

 I can wrap the save (2.2) and commit (3) in try/except blocks which
 solves the IntegrityError exceptions at that point. The problem is
 that I'm getting IntegrityError exceptions in the query section (1)
 what seem to be deferred INSERTS from the commit (3).

 How can I turn off the deferred inserts?


some sample code would be helpful here in order to get some context  
as to what youre doing.  if the problem is just that the INSERT's  
dont occur until you say session.commit(), you can issue session.flush 
() at any time which will flush all pending changes/new items to the  
database.


--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-01 Thread [EMAIL PROTECTED]

Hi Michael,

As I tried to show in the pseudo-code, the INSERTS look like they're
happening during the query (in step 1), well after the save/commit. I
even tried to add a flush and, when I turn on echo mode, I see inserts
happening at the query step. Is this even possible?

Mark

On Oct 1, 11:49 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Oct 1, 2007, at 11:02 AM, [EMAIL PROTECTED] wrote:





  Hi again, I really must be missing something fundamental here as I
  cannot seem to solve this problem:

  I have a loop that queries one table (without any contraints) and
  writes to a second table (with constraints). Here's what the loop
  looks like in pseudo-code:

  while True:
1) query old table and create a work list
2) while items are in the work list:
2.1) create a new object
2.2) save
3) commit

  I can wrap the save (2.2) and commit (3) in try/except blocks which
  solves the IntegrityError exceptions at that point. The problem is
  that I'm getting IntegrityError exceptions in the query section (1)
  what seem to be deferred INSERTS from the commit (3).

  How can I turn off the deferred inserts?

 some sample code would be helpful here in order to get some context
 as to what youre doing.  if the problem is just that the INSERT's
 dont occur until you say session.commit(), you can issue session.flush
 () at any time which will flush all pending changes/new items to the
 database.


--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-01 Thread Michael Bayer


On Oct 1, 2007, at 12:12 PM, [EMAIL PROTECTED] wrote:


 Hi Michael,

 As I tried to show in the pseudo-code, the INSERTS look like they're
 happening during the query (in step 1), well after the save/commit. I
 even tried to add a flush and, when I turn on echo mode, I see inserts
 happening at the query step. Is this even possible?

 Mark


OK by code example im looking for:

- are you on version 0.3 or 0.4 ?

- how are you creating your session ?

- using multiple threads ?  are you keeping each session local to a  
single thread ?

- whats happening between steps 3 and 1 ?  depending on how the  
session is set up, yes
a flush() can be issued right before the query executes (i.e.  
autoflush).  But, according to your
workflow below, it should not; since you are calling a commit() at  
the end.

- what kind of IntegrityError youre getting...duplicate row insert ?   
missing foreign key ?  no primary key ?



--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-01 Thread [EMAIL PROTECTED]

Hi Michael,

I'm creating the session by:

  Session = sessionmaker(bind = engine,
autoflush = True,
transactional = True)
  session = Session()

and I'm not using any threading at all (therefore no thread-local
storage). The only thing between the commit and the next query is some
reporting of statistics (using sys.stdout).

I'm getting a constraint violation IntegrityError.

Thanks again for any help!
Mark

On Oct 1, 12:47 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Oct 1, 2007, at 12:12 PM, [EMAIL PROTECTED] wrote:



  Hi Michael,

  As I tried to show in the pseudo-code, the INSERTS look like they're
  happening during the query (in step 1), well after the save/commit. I
  even tried to add a flush and, when I turn on echo mode, I see inserts
  happening at the query step. Is this even possible?

  Mark

 OK by code example im looking for:

 - are you on version 0.3 or 0.4 ?

 - how are you creating your session ?

 - using multiple threads ?  are you keeping each session local to a
 single thread ?

 - whats happening between steps 3 and 1 ?  depending on how the
 session is set up, yes
 a flush() can be issued right before the query executes (i.e.
 autoflush).  But, according to your
 workflow below, it should not; since you are calling a commit() at
 the end.

 - what kind of IntegrityError youre getting...duplicate row insert ?
 missing foreign key ?  no primary key ?


--~--~-~--~~~---~--~~
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: IntegrityError during query?

2007-10-01 Thread Michael Bayer


On Oct 1, 2007, at 2:29 PM, [EMAIL PROTECTED] wrote:


 Hi Michael,

 I'm creating the session by:

   Session = sessionmaker(bind = engine,
   autoflush = True,
   transactional = True)
   session = Session()

 and I'm not using any threading at all (therefore no thread-local
 storage). The only thing between the commit and the next query is some
 reporting of statistics (using sys.stdout).

 I'm getting a constraint violation IntegrityError.


unique constraint ? PK constraint ? foreign key constraint ?are  
you doing any explicit INSERT statements of your own independent of  
the session ?

I cant diagnose the problem any further on this end without an  
explicit example.



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