Forums

Accessing PA database from locally-hosted django

Hi there,

I have a small python service with a django frontend. The service pulls runtime information from the django database. Right now they both live on my laptop, and the service can directly reference django's connection to the database, to import models and use the ORM.

I'm in the process of putting the frontend live on PyAnywhere. I want to leave a copy of my django app on my laptop, and have it connected to the PyAnywhere database, so I can still reference the database through my local django, and have access to all the ORM tools.

Is it possible to point a local django to a PyAnywhere database? I've been trying with MySQL but perhaps could use SQLite.

Thanks! Peter

Just putting these resources together and getting a good idea for a solution:

https://help.pythonanywhere.com/pages/SSHTunnelling

http://stackoverflow.com/questions/16566942/connecting-django-to-a-db-behind-a-proxy

yup- you will have to use ssh tunnelling to connect your local django app to the PythonAnywhere database. Don't use sqlite for production webapps (it will probably have inconsistency problems when multiple threads write to it at the same time)