[sqlalchemy] Re: Forks() and Alchemy

2008-09-19 Thread Bobby Impollonia
If you have a session and then you fork, the child process is going to try to use the same session but that won't work because connections can't be floated across processes. If you call dispose() on the engine in the child process after forking (e.g., metadata.bind.dispose() ), then the child will

[sqlalchemy] Forks() and Alchemy

2008-09-19 Thread cono
Hi, I'm having problems with a process that uses an sqlAlchemy session, and after that it forks. From that moment I have 2 processes (can be more) that uses alchemy sessions. Both processes fails with "ProgrammingError: (ProgrammingError) SET TRANSACTION ISOLATION LEVEL must be called before any

[sqlalchemy] Re: BINARY Columns in MS SQL

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 4:14 PM, Rick Morrison wrote: > > Mike, any perspective on how difficult it might be to get the MSSQL > Dialect to emit the CONVERT syntax for binary fields, or would > converting the value itself using base64 encoding be the better path? we've had the notion of TypeEngi

[sqlalchemy] Re: BINARY Columns in MS SQL

2008-09-19 Thread John Hampton
John Hampton wrote: > This is the same conclusion that I had while talking with Mike on IRC. > Mike believes that there are others out there that use MSSQL and > SQLAlchemy that have BINARY columns working fine. I was hoping that > this is true and someone who has had success could share an ex

[sqlalchemy] Re: BINARY Columns in MS SQL

2008-09-19 Thread John Hampton
Rick Morrison wrote: > Hmmm, looks to me as if SQLA is generating the query correctly, but that > the DBAPI passes along the Binary() value encoded in a Python binary > string, which MSSQL then interprets as Varchar, and then complains that > it can't do an implicit conversion. That's a surpris

[sqlalchemy] Re: BINARY Columns in MS SQL

2008-09-19 Thread Rick Morrison
Hmmm, looks to me as if SQLA is generating the query correctly, but that the DBAPI passes along the Binary() value encoded in a Python binary string, which MSSQL then interprets as Varchar, and then complains that it can't do an implicit conversion. That's a surprise to me; I had thought that this

[sqlalchemy] Re: BINARY Columns in MS SQL

2008-09-19 Thread John Hampton
Rick Morrison wrote: > Is the column you're having issues with really a VARCHAR, or is the > message misleading? How did you create the table, pre-existing or via > SQLAlchemy? Can you show the schema and the code you're trying to access > it with? It's a preexisting table. The column in the

[sqlalchemy] Re: BINARY Columns in MS SQL

2008-09-19 Thread Rick Morrison
Hi John, Is the column you're having issues with really a VARCHAR, or is the message misleading? How did you create the table, pre-existing or via SQLAlchemy? Can you show the schema and the code you're trying to access it with? Thanks, Rick On Fri, Sep 19, 2008 at 2:54 PM, John Hampton <[EMAI

[sqlalchemy] BINARY Columns in MS SQL

2008-09-19 Thread John Hampton
I have a similar problem to Sam as shown in the following thread: http://groups.google.com/group/sqlalchemy/browse_thread/thread/3be1df474de602d0 I get the same error regarding conversion of VARCHAR to BINARY. The difference is that I am using pyodbc and unixODBC instead of pymssql. Is anyone

[sqlalchemy] Re: Using database functions in UPDATE statement

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 1:54 PM, Hans Lellelid wrote: > >> ah. right, the parameter argument of execute() does not handle SQL >> expressions as values - the keys are used to generate a corresponding >> list of bind parameter clauses. Earlier versions of SQLA were more >> liberal in this regard b

[sqlalchemy] Re: Using database functions in UPDATE statement

2008-09-19 Thread Hans Lellelid
> ah.   right, the parameter argument of execute() does not handle SQL   > expressions as values - the keys are used to generate a corresponding   > list of bind parameter clauses.   Earlier versions of SQLA were more   > liberal in this regard but the current behavior was based around   > simplif

[sqlalchemy] Re: Trouble inserting Binary into MSSQL DB's

2008-09-19 Thread Sam Widmer
Thanks I'll go ahead and do that. On Fri, Sep 19, 2008 at 10:30 AM, Michael Bayer <[EMAIL PROTECTED]>wrote: > > > On Sep 19, 2008, at 1:24 PM, Sam Widmer wrote: > > > Thanks for the responses so far. > > > > The reason we tried pymssql is because it is much easier to get > > running on OSX. At

[sqlalchemy] Re: Trouble inserting Binary into MSSQL DB's

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 1:24 PM, Sam Widmer wrote: > Thanks for the responses so far. > > The reason we tried pymssql is because it is much easier to get > running on OSX. At the moment our efforts to get pyodbc working on > Macs have met with alot of frustration. > > However, we would have don

[sqlalchemy] Re: Using database functions in UPDATE statement

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 1:18 PM, Hans Lellelid wrote: > > In response to myself ... I discovered that it was only when I was > specifying the function clauses as bind params in the conn.execute() > method that it was failing. The code I presented should actually be > working correctly. > > To be ex

[sqlalchemy] Re: Using database functions in UPDATE statement

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 12:52 PM, Hans Lellelid wrote: > > Hi, > > I'm using SA 0.4.6 and I'm having trouble using the result of a > database function / stored procedure in an UPDATE statement (being > constructed with SQL expression lang). This happens to be for using > PostGIS columns; however,

[sqlalchemy] Re: Trouble inserting Binary into MSSQL DB's

2008-09-19 Thread Sam Widmer
Thanks for the responses so far. The reason we tried pymssql is because it is much easier to get running on OSX. At the moment our efforts to get pyodbc working on Macs have met with alot of frustration. However, we would have done things differently if we had seen different wording in the SqlAl

[sqlalchemy] Re: Using database functions in UPDATE statement

2008-09-19 Thread Hans Lellelid
In response to myself ... I discovered that it was only when I was specifying the function clauses as bind params in the conn.execute() method that it was failing. The code I presented should actually be working correctly. To be explicit, this seems to be working: mytable.update(mytable.c.id==i

[sqlalchemy] Re: grandparent id relation

2008-09-19 Thread az
On Friday 19 September 2008 18:53:17 Michael Bayer wrote: > On Sep 19, 2008, at 11:47 AM, GHZ wrote: > > On Sep 18, 2:54 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > >> 2. more involved: catch change events and populate a > >> Child.grandparent > >> relation(). 0.5 has made the AttributeExten

[sqlalchemy] Using database functions in UPDATE statement

2008-09-19 Thread Hans Lellelid
Hi, I'm using SA 0.4.6 and I'm having trouble using the result of a database function / stored procedure in an UPDATE statement (being constructed with SQL expression lang). This happens to be for using PostGIS columns; however, that is not relevant to the problem here. I have tried doing some

[sqlalchemy] Re: grandparent id relation

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 11:47 AM, GHZ wrote: > > On Sep 18, 2:54 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: >> 2. more involved: catch change events and populate a >> Child.grandparent >> relation(). 0.5 has made the AttributeExtension API public which >> would be a good place to catch this ev

[sqlalchemy] Re: grandparent id relation

2008-09-19 Thread GHZ
On Sep 18, 2:54 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > 2. more involved: catch change events and populate a Child.grandparent   > relation().   0.5 has made the AttributeExtension API public which   > would be a good place to catch this event.  The advantage to this is   > that your Child

[sqlalchemy] Re: How to determine the right number of pooled connections to use

2008-09-19 Thread Alen Ribic
On Sep 19, 5:21 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Sep 19, 2008, at 11:16 AM, Alen Ribic wrote: > > if the thread in which the request was served continues to run, not   > serve further requests, and does not clean up after itself, then the   > connections held open local to that

[sqlalchemy] Re: Trouble inserting Binary into MSSQL DB's

2008-09-19 Thread Rick Morrison
There's no doubt that pyodbc is the better-supported option; the pymssql module hasn't been updated in two years, and it relies on the Microsoft DB lib, which has been deprecated for a long, long time and is no longer supported, and may not even work with MSSQL 2008. Here's the deprecation notice f

[sqlalchemy] Re: How to determine the right number of pooled connections to use

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 11:16 AM, Alen Ribic wrote: > > Michael, thank you for you reply. > Question: if my web request fails to return a response, hence request > method doesn't exit gracefully, could that perhaps cause a connection > not to be returned to a connection pool? Reason I ask this is th

[sqlalchemy] Re: How to determine the right number of pooled connections to use

2008-09-19 Thread Alen Ribic
Michael, thank you for you reply. Question: if my web request fails to return a response, hence request method doesn't exit gracefully, could that perhaps cause a connection not to be returned to a connection pool? Reason I ask this is that if my thinking is right, I might have a clue to exactly w

[sqlalchemy] Re: How to determine the right number of pooled connections to use

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 10:05 AM, Alen Ribic wrote: > > Good day. > > I tried to perform a load test on my python web app using sqlalchemy > as follows: > 1000 requests > 20 concurrent connections > > Towards the end, I started getting an error from sqlalchemy module: > TimeoutError: QueuePool limit

[sqlalchemy] How to determine the right number of pooled connections to use

2008-09-19 Thread Alen Ribic
Good day. I tried to perform a load test on my python web app using sqlalchemy as follows: 1000 requests 20 concurrent connections Towards the end, I started getting an error from sqlalchemy module: TimeoutError: QueuePool limit of size 40 overflow 10 reached, connection timed out, timeout 30 I

[sqlalchemy] Re: Trouble inserting Binary into MSSQL DB's

2008-09-19 Thread Michael Bayer
On Sep 19, 2008, at 3:25 AM, [EMAIL PROTECTED] wrote: > > I am having a problem inserting binary data into an existing MS DB. > > A very simple example is like this > > class FooTable: > __tablename__ = 'mytable' > keycol = Column(String(15), nullable=False, primary_key=True) > bincol = Colum

[sqlalchemy] Re: Problem with coverage and sqlalchemy declarative synonym?

2008-09-19 Thread Michael Bayer
On Sep 18, 2008, at 4:08 PM, Doug Latornell wrote: > > With some help from Ned Batchelder I was able to confirm that this is > a Python bug: http://bugs.python.org/issue1569356 that has been fixed > since the 2.5.2 release. Ned confirmed that the fix is included in > Python 2.6a3. well thats.

[sqlalchemy] Trouble inserting Binary into MSSQL DB's

2008-09-19 Thread widmer . sam
I am having a problem inserting binary data into an existing MS DB. A very simple example is like this class FooTable: __tablename__ = 'mytable' keycol = Column(String(15), nullable=False, primary_key=True) bincol = Column(Binary(4), nullable=False) def __init__(self, keyval, binval):