1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

[boulder-oracle-sprint] remove backend.quote_name()

git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4005 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters 2006-11-04 23:50:02 +00:00
parent 955424507b
commit 05024929cf

View File

@ -37,7 +37,7 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
cursor = connection.cursor()
try:
_create_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
_create_test_db(cursor, TEST_DATABASE_NAME, verbosity)
except Exception, e:
sys.stderr.write("Got an error creating the test database: %s\n" % e)
if not autoclobber:
@ -46,10 +46,10 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
try:
if verbosity >= 1:
print "Destroying old test database..."
_destroy_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
_destroy_test_db(cursor, TEST_DATABASE_NAME, verbosity)
if verbosity >= 1:
print "Creating test database..."
_create_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
_create_test_db(cursor, TEST_DATABASE_NAME, verbosity)
except Exception, e:
sys.stderr.write("Got an error recreating the test database: %s\n" % e)
sys.exit(2)
@ -64,7 +64,7 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
# the side effect of initializing the test database.
cursor = connection.cursor()
def destroy_test_db(settings, connection, backend, old_database_name, verbosity=1):
def destroy_test_db(settings, connection, old_database_name, verbosity=1):
if verbosity >= 1:
print "Destroying test database..."
connection.close()
@ -74,46 +74,42 @@ def destroy_test_db(settings, connection, backend, old_database_name, verbosity=
cursor = connection.cursor()
time.sleep(1) # To avoid "database is being accessed by other users" errors.
_destroy_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
_destroy_test_db(cursor, TEST_DATABASE_NAME, verbosity)
connection.close()
def _create_test_db(cursor, backend, dbname, verbosity):
def _create_test_db(cursor, dbname, verbosity):
if verbosity >= 2:
print "_create_test_db(): dbname = %s" % dbname
statements = [
"""create tablespace "%(user)s"
datafile '%(datafile)s' size 10M autoextend on next 10M maxsize 20M
"""create tablespace %(user)s
datafile '%(user)s.dbf' size 10M autoextend on next 10M maxsize 20M
""",
"""create temporary tablespace %(user_temp)s
tempfile '%(tempfile)s' size 10M autoextend on next 10M maxsize 20M
"""create temporary tablespace %(user)s_temp
tempfile '%(user)s_temp.dbf' size 10M autoextend on next 10M maxsize 20M
""",
"""create user %(user)s
identified by %(password)s
default tablespace %(user)s
temporary tablespace %(user_temp)s
temporary tablespace %(user)s_temp
""",
"""grant resource to %(user)s""",
"""grant connect to %(user)s""",
]
_execute_statements(cursor, statements, backend, dbname, verbosity)
_execute_statements(cursor, statements, dbname, verbosity)
def _destroy_test_db(cursor, backend, dbname, verbosity):
def _destroy_test_db(cursor, dbname, verbosity):
if verbosity >= 2:
print "_destroy_test_db(): dbname=%s" % dbname
statements = [
"""drop user %(user)s cascade""",
"""drop tablespace %(user)s including contents and datafiles cascade constraints""",
"""drop tablespace %(user_temp)s including contents and datafiles cascade constraints""",
"""drop tablespace %(user)s including contents and datafiles cascade constraints""",
]
_execute_statements(cursor, statements, backend, dbname, verbosity)
_execute_statements(cursor, statements, dbname, verbosity)
def _execute_statements(cursor, statements, backend, dbname, verbosity):
def _execute_statements(cursor, statements, dbname, verbosity):
for template in statements:
stmt = template % {'user': backend.quote_name(dbname),
'user_temp': backend.quote_name(dbname + '_temp'),
# purposefully *not* using backend.quote_name here
'tempfile': dbname + '_temp.dat',
'datafile': dbname + '.dbf',
stmt = template % {'user': dbname,
'password': "Im a lumberjack"}
if verbosity >= 2:
print stmt