Django use multiple databases [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to make a Django website as a user interface for data I've collected through a scraper. The scraper generates (and constantly updates) a database and I'd like Django to interact with it as well.
I need to run the scraper program often, is there a way I can do this through Django's admin? Like manage the backend that doesn't have to do with Django directly?
Should I merge the databases (scraper and Django)?
Is there a proper way of doing this?
Thanks in advance.

Django supports multiple databases. You can leave your scraping program/database as is and simply access the database through Django. Set up models as you normally would - but in the META field set managed = False. This will prevent Django from applying migrations to the databases.
If you find you do want to manage the database through Django models you will need to set up a routing class to make sure your app only targets the intended database.

Related

Is SQL or NoSQL a better choice for a beginner Django project? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
When it comes to actually deploying a Django project, is SQL software, like PostegreSQL, or NoSQL, like MongoDB, a better option?
To evaluate which might be a better choice, you can consider:
requires less changes to the actual code of the already existing project - for example having to re-do the models structure,
has correct integration with the backend, i.e.: some years ago MongoDB wouldn't integrate with the Django backend,
is more beginner friendly.
Edit
For this example's sake, let's set some information:
the project uses models such as client, booking, flight, hotel.
it uses with ForeignKeys.
it connects a model client with django's own User model.
Data needs to be retrieved both to client side and administration side.
JSON might be used, if necessary, at some point in the future.
A SQL DB would be appropriate for this project. This is due to the use of foreign keys, the nature of the models and the relationship between client and user.
You will want to be able to store structured data and be able to maintain relationships between that data, this can be achieved with SQL.

How to design a database for an eCommerce website using Django [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm new to Django and I'm trying to build an eCommerce website, but I'm facing a problem of storing data of products that don't share the same attributes. I'm wondering which database technologies to use and how design database in such way that I could store different products attributes without problems.
Django is good with RDB (Relationals Data Bases).
Dealing with undetermined data, you need to use JSON storage format because you don't know what attributes have the model. Non-Relationals Data Bases are good for that, but, RDB isn't. You can use MongoDB for storage that JSON info, but there born a new question:
When to use MongoDB with Django?
Short Answer: You don't.
Source: when to use mongodb with django
You can use Postgresql JSON field implementation in Django.
from django.contrib.postgres.fields import JSONField
from django.db import models
class Product(models.Model):
metadata = JSONField(null=True, blank=True)

What would be the easiest way to add a database to html file? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
So I have made a project website with a couple html files, css and some javascript. I was thinking that I would add a login functionality and some other things like that. So I set off to find out what would be good for it. Now its is hard for me because I can't decide which one to use. I saw Django on python but I had to make a whole new project for it and I have to start from scratch. I was just thinking I would add a database to this site using something. I am just doing some lightweight things. What should I use? Thank you.
Well if you are not going to use python for this with Django, you could use PHP and MySQL. I do it all the time for small sites. Basically just go to your hosting panel and create a new DB and then use php to create a connection script and then go from there as far as adding and using the database. All web hosts support this feature that I know of. If you go with Django though, you can simply add the sqllite3 DB or use something like MongoDB or any other DB out there really. Please look up the exact documentation for whichever route you choose.

Is there much change in python code when I want to change the database from sqlite to postgres? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So far I've been using sqlite with django, however I might want to deploy it to heroku and therefore use postgresql instead. Other than installing postgres, connect it to my app and repopulate it with the same data, are there any necessary change in my python code? For example the models, queries to get the data, lines that perform adding data to my database, and so on. Does those things need change or is the syntax still the same?
If you're not using specific Django ORM's features like manual SQL queries etc, it's straightforward to migrate to a different db.
You need to change the DATABASE config and its ENGINE entry to django.db.backends.postgresql.
Of course, you need to test it after db change and before deployment.
For more see supported engines and databases details

How to get django admin app working with mongodb? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to use mongodb together with django. I mainly use the admin app of django.
I noticed that there are 2 mongodb orms for django.
One is mongoengine, https://github.com/MongoEngine/mongoengine
Another is mongodb-engine from the django-nonrel group.
https://github.com/django-nonrel/mongodb-engine
What I want to know is that whether django's admin app works fine with the two. If not,
which one is better.
Also, I want to know whether 3rd party apps would work if I use mongodb with django? Which of the two orms is more friendly with 3rd party apps?
At first glance, mongodb-engine seems to be more friendly, but it depends on django-nonrel,
which is based on django 1.5. If I want to use recent version of django, mongoengine seems to be the better choice, also mongoengine development seems more active.
The short answer is yes. Django works well with MongoDB.
Please check this thread for more relevant answers: On Using Django with MongoDB
Hope it helps.

Categories

Resources