mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09: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:
parent
955424507b
commit
05024929cf
@ -37,7 +37,7 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
|
|||||||
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
try:
|
try:
|
||||||
_create_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
|
_create_test_db(cursor, TEST_DATABASE_NAME, verbosity)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
sys.stderr.write("Got an error creating the test database: %s\n" % e)
|
sys.stderr.write("Got an error creating the test database: %s\n" % e)
|
||||||
if not autoclobber:
|
if not autoclobber:
|
||||||
@ -46,10 +46,10 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
|
|||||||
try:
|
try:
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
print "Destroying old test database..."
|
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:
|
if verbosity >= 1:
|
||||||
print "Creating test database..."
|
print "Creating test database..."
|
||||||
_create_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
|
_create_test_db(cursor, TEST_DATABASE_NAME, verbosity)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
sys.stderr.write("Got an error recreating the test database: %s\n" % e)
|
sys.stderr.write("Got an error recreating the test database: %s\n" % e)
|
||||||
sys.exit(2)
|
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.
|
# the side effect of initializing the test database.
|
||||||
cursor = connection.cursor()
|
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:
|
if verbosity >= 1:
|
||||||
print "Destroying test database..."
|
print "Destroying test database..."
|
||||||
connection.close()
|
connection.close()
|
||||||
@ -74,46 +74,42 @@ def destroy_test_db(settings, connection, backend, old_database_name, verbosity=
|
|||||||
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
time.sleep(1) # To avoid "database is being accessed by other users" errors.
|
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()
|
connection.close()
|
||||||
|
|
||||||
def _create_test_db(cursor, backend, dbname, verbosity):
|
def _create_test_db(cursor, dbname, verbosity):
|
||||||
if verbosity >= 2:
|
if verbosity >= 2:
|
||||||
print "_create_test_db(): dbname = %s" % dbname
|
print "_create_test_db(): dbname = %s" % dbname
|
||||||
statements = [
|
statements = [
|
||||||
"""create tablespace "%(user)s"
|
"""create tablespace %(user)s
|
||||||
datafile '%(datafile)s' size 10M autoextend on next 10M maxsize 20M
|
datafile '%(user)s.dbf' size 10M autoextend on next 10M maxsize 20M
|
||||||
""",
|
""",
|
||||||
"""create temporary tablespace %(user_temp)s
|
"""create temporary tablespace %(user)s_temp
|
||||||
tempfile '%(tempfile)s' size 10M autoextend on next 10M maxsize 20M
|
tempfile '%(user)s_temp.dbf' size 10M autoextend on next 10M maxsize 20M
|
||||||
""",
|
""",
|
||||||
"""create user %(user)s
|
"""create user %(user)s
|
||||||
identified by %(password)s
|
identified by %(password)s
|
||||||
default tablespace %(user)s
|
default tablespace %(user)s
|
||||||
temporary tablespace %(user_temp)s
|
temporary tablespace %(user)s_temp
|
||||||
""",
|
""",
|
||||||
"""grant resource to %(user)s""",
|
"""grant resource to %(user)s""",
|
||||||
"""grant connect 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:
|
if verbosity >= 2:
|
||||||
print "_destroy_test_db(): dbname=%s" % dbname
|
print "_destroy_test_db(): dbname=%s" % dbname
|
||||||
statements = [
|
statements = [
|
||||||
"""drop user %(user)s cascade""",
|
"""drop user %(user)s cascade""",
|
||||||
"""drop tablespace %(user)s including contents and datafiles cascade constraints""",
|
"""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:
|
for template in statements:
|
||||||
stmt = template % {'user': backend.quote_name(dbname),
|
stmt = template % {'user': dbname,
|
||||||
'user_temp': backend.quote_name(dbname + '_temp'),
|
|
||||||
# purposefully *not* using backend.quote_name here
|
|
||||||
'tempfile': dbname + '_temp.dat',
|
|
||||||
'datafile': dbname + '.dbf',
|
|
||||||
'password': "Im a lumberjack"}
|
'password': "Im a lumberjack"}
|
||||||
if verbosity >= 2:
|
if verbosity >= 2:
|
||||||
print stmt
|
print stmt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user