blob: 0387ea258984ae308b26eb16870fddec374f5ba4 [file] [log] [blame]
import logging
import os
import common
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'autotest_lib.frontend.settings')
def _enable_autocommit_by_name(name):
"""Enable autocommit for the connection with matching name.
@param name: Name of the connection.
"""
from django.db import connections
# ensure a connection is open
logging.info('Enabling autocommit for %s(%s)',
name, connections[name].settings_dict['HOST'])
connections[name].cursor()
connections[name].connection.autocommit(True)
def enable_autocommit():
"""Enable autocommit for default and global connection.
"""
_enable_autocommit_by_name('default')
_enable_autocommit_by_name('global')