How to config Django using pymysql as driver?

前端 未结 2 1347
遥遥无期
遥遥无期 2020-12-08 05:25

I\'m new to Django. It wasted me whole afternoon to config the MySQL engine. I am very confused about the database engine and the database driver. Is the engine

相关标签:
2条回答
  • 2020-12-08 05:51

    You can import pymsql so it presents as MySQLdb. You'll need to do this before any django code is run, so put this in your manage.py file

    import pymysql
    pymysql.install_as_MySQLdb()
    
    0 讨论(0)
  • 2020-12-08 06:05

    The short answer is no they are not the same.

    The engine, in a Django context, is in reference to RDBMS technology. The driver is the library developed to facilitate communication to that actual technology when up and running. Letting Django know what engine to use tells it how to translate the ORM functions from a backend perspective. The developer doesn't see a change in ORM code but Django will know how to convert those actions to a language the technology understands. The driver then takes those actions (e.g. selects, updates, deletes) and sends them over to a running instance to facilitate the action.

    0 讨论(0)
提交回复
热议问题