[Answer]-I get error when I try to check my MySQLdb connector in Django shell

1👍

“The object django.db.connection represents the default database connection. To use the database connection, call connection.cursor() to get a cursor object. Then, call cursor.execute(sql, [params]) to execute the SQL and cursor.fetchone() or cursor.fetchall() to return the resulting rows.”

https://docs.djangoproject.com/en/1.7/topics/db/sql/#executing-custom-sql-directly

So, if you need connection object you should do:

connection = django.db.connection

Django use persistent connection to database, so you no need to initialize it.

Leave a comment