On Wed, Jun 08, 2016 at 06:14:44PM -0700, Brandon wrote:
> Hi! I am attempting to create my own database connector for Django for an 
> external PostgreSQL DB that I have running. For this application, I issue 
> the SQL queries and get responses over a REST API, so in theory, I'd like 
> to adopt what already exists in the Postgres connector 
> (django.db.backends.postgresql_psycopg2 I believe). Ideally, my hope is 
> that I'd just override the psycopg2 call to the Postgres DB with my own 
> call to my REST API, since the SQL query is the same. But I'm having 
> trouble figuring out where this can go and if it can be this simple. Any 
> help or advice would be much appreciated, thanks in advance!

Hi Brandon,

In order for this to work, you'd need to reimplement a Python
DBAPI-compatible wrapper around your REST API with support for a bunch
of non-trivial features, such as correct parameter substitution, or
type handling. Also, you'd probably need to implement transaction
handling somehow, which will be a non-trivial thing, because
transactions by definition rely on some state of a database
connection, whereas REST is supposed to be stateless.

Overall, this does not sound like a good idea to me, and I would
strongly recommend using a regular Postgres database connection
instead.

Cheers,

Michal

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160609213019.GF29054%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to