How can i share one Database Sqlite between 2 app on pythonanywhere

62 views
Skip to first unread message

Balaji Shetty

unread,
Sep 4, 2019, 1:10:39 AM9/4/19
to django...@googlegroups.com
Hi Everyone

Can anybody suggest me
How can i share one Database Sqlite between 2 app on pythonanywhere.

Currently i have deployed one project on PythonAnywhere.
I have purchases 2 App.
Now i can execute 2 App simultaneous.


app1.pythonanywhere.com is my real time hosted project. Before making any changes, i create mirror copy of code and Database Sqlite on app2.pythonanywhere.com, make changes and if changes are proper. I make changes in

But it is time consuming Process. Better solution may be share database and make changes in Business Logic and reflect in orignal one.

My Simple Question is
How can i share sqlite database between two Project here.

OR

Is there any other way to do the same thing more efficiently?

Thanks in Advance.
--
Mr. Shetty Balaji S.
Asst. Professor
Department of Information Technology,
SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India
  Mobile: +91-9270696267

Jay Vasant

unread,
Sep 4, 2019, 8:32:14 AM9/4/19
to django...@googlegroups.com
It isn't possible to share a local db between two apps.

Here are the alternatives you can use:
  • Create api's for all the operations you want to perform.
  • Use an hosted db service(e.g. Postgres on heroku).

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAECSbOv7vBQ8hxZBoPf2PvVgUY2NS-44-yvLuprbphdvN1ZJYw%40mail.gmail.com.

Mario R. Osorio

unread,
Sep 4, 2019, 11:43:30 AM9/4/19
to Django users
You have at least 2 possibilities, depending on your exact needs:

1- The preferred method is to Import the models from the app they reside at, like in:

        from foo_app.models import bar_model

2- You could also have the models you need to share created at the project level thus making them available to all and any of your apps (this method is rather frowned upon)

3- If what you need is not the share the data among your apps but the structure of the tables, you could also use "abstract base classes". and use use them like in the 2 previous options.

HTH

Amirhosein Rajabi

unread,
Sep 5, 2019, 12:39:54 PM9/5/19
to Django users
I have shared a MySQL database even between two accounts in PythonAnyWhere. But I think there is no possible way for local DBs. If you can access the app1 files from the app2 or otherwise, you may be able to change settings.py for that db.sqlite path.
Reply all
Reply to author
Forward
0 new messages