As we learned earlier in this book, Django’s ORM API is one of its standout features with which the database interaction becomes much more Pythonic, rather than having to execute raw SQL queries. However, it is too tightly coupled with the other features of the Django framework – such as the migrations, the admin interface, and more. There are other ORM libraries for Python, notably SQLAlchemy, SQLObject, etc., which are far more flexible. SQLAlchemy offers support for a wider range of databases and works well with other frameworks like Flask. Hence, if someone wants to port a Flask application to Django, is it possible to use SQLAlchemy with Django, and if yes, how? We shall find an answer to this in this chapter.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Django: Using Databases

  • Malhar Lathkar

摘要

As we learned earlier in this book, Django’s ORM API is one of its standout features with which the database interaction becomes much more Pythonic, rather than having to execute raw SQL queries. However, it is too tightly coupled with the other features of the Django framework – such as the migrations, the admin interface, and more. There are other ORM libraries for Python, notably SQLAlchemy, SQLObject, etc., which are far more flexible. SQLAlchemy offers support for a wider range of databases and works well with other frameworks like Flask. Hence, if someone wants to port a Flask application to Django, is it possible to use SQLAlchemy with Django, and if yes, how? We shall find an answer to this in this chapter.