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
How can I configure Django with SQLAlchemy?
You can use SQLAlchemy within a Django project with Aldjemy:
https://github.com/Deepwalker/aldjemy
Check this:
Replacing django orm
alchemy? :)
Google links:
replacing-django-s-orm-with-sqlalchemy
django-sqlalchemy
googleGroups
Please find this little tutorial on how to use SQLAlchemy with Django
There are many benefits of using SQLAlchemy instead of Django ORM, but consider developing a built-in-Django choice of SQLAlchemy
(to have something called a production ready)
By the way, Django ORM is going better - in Django 1.11 they added UNION support (a SQL basic operator), so maybe some day there will be no need to change ORM.
Related
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 7 months ago.
Improve this question
I know there is an included library in python for SQLite3, and when I was studying Flask the course instructor proposed to use SQLAlchemy to manage an SQLite database, What´s the difference between using sqlite3 library and SQLAlchemy?
SQLAlchemy is an ORM based tool: https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping. It therefore can create and support complex objects, relationships and structures, which is more than an simple API interface with database. I am guessing here, but the SQLite3 library is probably little more than what you need to interface with the database engine. In principle, all database drivers can be used with SQLAlchemy.
I hope this helps.
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 am new to Flask development. But I noticed that people are using SQLAlchemy even when they are using PostgreSQL as their database. I am wondering why is it required. Thanks in advance.
You don't need to use SQLAlchemy with Flask and Postgresql. Under the hood, SQLAlchemy makes use of the Psycopg database adapter (http://initd.org/psycopg/docs/) and you can use that directly in a Flask application if you wish.
The main reasons most people probably choose to use SQLAlchemy are:
The ORM (object-relational-mapper http://docs.sqlalchemy.org/en/latest/orm/tutorial.html) - this makes it really easy to map your python classes directly to database tables and makes it possible to manipulate the database via your python objects
Session awareness (http://flask.pocoo.org/docs/0.12/patterns/sqlalchemy/) - SQLAlchemy can integrated in Flask in such a way as to provide a database transaction lifespan that matches the lifespan of an incoming web request - essentially you get a unique database connection for each request, providing a nice level of isolation
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.
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
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.