Here is what I have:
from django.db import connection
class Command(BaseCommand):
option_list = BaseCommand.option_list
def handle(self, *labels, **options):
with connection.cursor() as cursor:
# Drop database
cursor.execute("drop database if exists test_db;")
# Create database again
cursor.execute("create database test_db;")
Where in this block can I close the db cursor and connection and what do I call to close them?
Found the solution.
I close the connection out of the "with" block with connection.close() and that solves it.
Thank you