setup_django_environment.py revision 722c3e77029c6533c17ae3591563be2caae6ea69
1import os 2 3import common 4 5os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'autotest_lib.frontend.settings') 6 7def _enable_autocommit_by_name(name): 8 """Enable autocommit for the connection with matching name. 9 10 @param name: Name of the connection. 11 """ 12 from django.db import connections 13 # ensure a connection is open 14 connections[name].cursor() 15 connections[name].connection.autocommit(True) 16 17 18def enable_autocommit(): 19 """Enable autocommit for default and global connection. 20 """ 21 _enable_autocommit_by_name('default') 22 _enable_autocommit_by_name('global') 23