I'm working with a Postgresql database with Django. Because of licensing 
reasons, I can't use psycopg2 , so I'm using the alternative pygresql.

I don't need to use the Django ORM at all, I simply need the cursor for 
cur.execute() and cur.fetchall().

Since pygresql doesn't have a Django backend connector, I can't use the 
pygresql pgdb module in the Database settings in settings.py; I've to 
manually open up a connection object.

What would be the best practice to do this? Currently I've simply created 
the connection object conn=pgdb.connect(params) in views.py outside of all 
functions, but this seems a bit hacky and I do get 'ProgrammingError: 
Server Closed the connection unexpectedly' errors here and there.

One approach might be to simply create an executeQuery() function which 
Opens a connection, executes a query, and closes it each time I want to 
execute a query. But I'm not sure if that's best practice and whether it 
would cause any issues.

Any tips?

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8ce2851a-7793-4bba-9761-3a4ba0cbf066%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to