[sqlalchemy] Re: SQLAlchemy experts wanted

2008-05-18 Thread Michael Bayer


On May 16, 2008, at 3:23 PM, Jim R. Wilson wrote:


 Hi all,

 SQLAlchemy is a great project and a growing niche.  As it becomes even
 more popular, there will be increasing demand for experts in the
 field.

 I am compiling a contact list of SQLAlchemy experts who may be
 interested in opportunities under the right circumstances.  I am not a
 recruiter - I'm a regular developer who sometimes gets asked for
 referrals when I'm not personally available.


and we'll call it. The Alchemist's Guild (tm)

--~--~-~--~~~---~--~~
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: composite primary key/postgres

2008-05-18 Thread Arlo Belshee

Here's the TSQL for a unique index:

CREATE UNIQUE NONCLUSTERED INDEX IX_UQ_Sample ON Sample (
first ASC, other ASC, something ASC)

I defined Sample as:

CREATE TABLE Sample(
first int NOT NULL, something int NULL, other bit NULL)

I don't know how you'd get SqlAlchemy to generate this when it makes
tables for you.

 actualy this whole mess is because... i need an unique constraint on
 that set of foreign keys, but mssql refused to have unique
 constraints other than the primary key, hence i forced it to be the
 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: composite primary key/postgres

2008-05-18 Thread Michael Bayer





On May 18, 2008, at 11:34 AM, Arlo Belshee wrote:


 Here's the TSQL for a unique index:

 CREATE UNIQUE NONCLUSTERED INDEX IX_UQ_Sample ON Sample (
   first ASC, other ASC, something ASC)

 I defined Sample as:

 CREATE TABLE Sample(
   first int NOT NULL, something int NULL, other bit NULL)

 I don't know how you'd get SqlAlchemy to generate this when it makes
 tables for you.



theres a ddl() construct used for this.  Some docs are at:  
http://www.sqlalchemy.org/docs/04/sqlalchemy_schema.html#docstrings_sqlalchemy.schema_DDL



--~--~-~--~~~---~--~~
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: retrieving mapped objects from within a session

2008-05-18 Thread Moshe C.

Got back to this issue after a while.

The SessionExtension objects allows me to hook on to a session and get
notified of various events.

My question is different:
Given a session, before commit, how can I query it to know what is
going to happen at commit.
My intention is to derive from that, a corresponding change to another
table, for the purpose of audit trail.


On Apr 6, 7:40 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Apr 6, 2008, at 11:44 AM,MosheC. wrote:



  Is it possible to retrieve mapped objects from a session.

  The motivation: I want to maintain history log tables where a row is
  added per  each update or insert on the corresponding main table. The
  schema of the tables is identical except for an additional timestamp
  in the history table.

  I want to do this in one place and wrapping the commit() function
  seems appropriate.

 take a look at SessionExtension:  
 http://www.sqlalchemy.org/docs/04/sqlalchemy_orm_session.html#docstri...
--~--~-~--~~~---~--~~
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: retrieving mapped objects from within a session

2008-05-18 Thread Michael Bayer


On May 18, 2008, at 2:09 PM, Moshe C. wrote:


 Got back to this issue after a while.

 The SessionExtension objects allows me to hook on to a session and get
 notified of various events.

 My question is different:
 Given a session, before commit, how can I query it to know what is
 going to happen at commit.
 My intention is to derive from that, a corresponding change to another
 table, for the purpose of audit trail.

audit trails are most easily accomplished using a MapperExtension,  
which will give you hooks to execute additional SQL before or after  
each instance is inserted, updated, or deleted.   
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_extending



--~--~-~--~~~---~--~~
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] transactional sessions not transactional?

2008-05-18 Thread Matthew Dennis
The following test case of mine fails on PG 8.3 and SA 0.4.3  Basically,
create two sessions, make some changes in the first and obverse they are
visible before commit/rollback in the second (and via connectionless
execution directly on the engine), but become unvisible after rollback.  The
first two print statements both show a row returned (that should only be
visible from s0), but after the rollback the print statements show there are
no values.  It's almost like a threadlocal strategy is being used when it
was never configured.  Ideas/thoughts/comments?

#!/usr/bin/python


from sqlalchemy.sql import text
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

engine = create_engine('postgres://[EMAIL PROTECTED]/testsatransaction')
new_session = sessionmaker(bind=engine, transactional=True)
engine.execute(text(drop table if exists foo))
engine.execute(text(create table foo(c1 int)))
s0 = new_session()
s1 = new_session()
s0.execute(text(insert into foo values(1)))
(one,) = s0.execute(text(select * from foo)).fetchone()
assert one == 1
print engine.execute(text(select * from foo)).fetchone()
print s1.execute(text(select * from foo)).fetchone()
s0.rollback()
print engine.execute(text(select * from foo)).fetchone()
print s1.execute(text(select * from foo)).fetchone()

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