Wednesday, August 28, 2013

Re: Share connection between Django and SqlAlchemy

Hi, I am also going share Django ORM and SQLAlchemy connections.
Do you know the solution?

Thomas

W dniu środa, 22 czerwca 2011 20:38:54 UTC+2 użytkownik Vladimir Mihailenco napisał:
I am trying to share connection between Django and SqlAlchemy. I tried
following code:

from django.db import connection
from sqlalchemy import create_engine

def get_connection():
    if connection.connection is None:
        connection._cursor()  # TODO: better way to open new
connection?
    return connection.connection

engine = create_engine('postgresql+psycopg2://',
                       creator=get_connection)
engine.execute(s) # s - SqlAlchemy query

But this results in various fails in SqlAchemy (like connection is
already closed, can't execute some queries). More details are
available here: http://stackoverflow.com/questions/6439119/django-and-sqlalchemy-share-connection

So I have following question:

- does anyone know working solution?
- how big will be performance impact if I use separate connection for
Django and SqlAlchemy?
- any explanations why current code is not working :)

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment