summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2015-09-23 18:29:04 +0200
committerAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2015-09-23 19:44:15 +0200
commit29533a0f52eac4f99e8e06a5ed49043eedd99e52 (patch)
tree6ba471d8f785a5665d06c10152d220d7695c90e3
parentfaa1cfcd9f21c1bc74e251f022029e52069fcd18 (diff)
downloadbcfg2-29533a0f52eac4f99e8e06a5ed49043eedd99e52.tar.gz
bcfg2-29533a0f52eac4f99e8e06a5ed49043eedd99e52.tar.bz2
bcfg2-29533a0f52eac4f99e8e06a5ed49043eedd99e52.zip
tools/upgrade: Support multiple databases
Do not use the global django connection object but the matching instance from the django connections list.
-rwxr-xr-xtools/upgrade/1.3/migrate_dbstats.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py
index 2a2a112e9..c788aae37 100755
--- a/tools/upgrade/1.3/migrate_dbstats.py
+++ b/tools/upgrade/1.3/migrate_dbstats.py
@@ -8,7 +8,8 @@ import logging
import time
import Bcfg2.Logger
import Bcfg2.Options
-from django.db import connection, transaction, backend
+from Bcfg2.DBSettings import get_db_label
+from django.db import transaction, backend, connections
from Bcfg2.Server.Admin import UpdateReports
from Bcfg2.Reporting.utils import BatchFetch
from Bcfg2.Reporting.Compat import transaction
@@ -28,7 +29,8 @@ def _quote(value):
global _our_backend
if not _our_backend:
try:
- _our_backend = backend.DatabaseOperations(connection)
+ _our_backend = backend.DatabaseOperations(
+ connections[get_db_label('Reporting')])
except TypeError:
_our_backend = backend.DatabaseOperations()
return _our_backend.quote_name(value)
@@ -178,7 +180,7 @@ def _shove(old_table, new_table, columns):
cols,
_quote(old_table))
- cursor = connection.cursor()
+ cursor = connections[get_db_label('Reporting')].cursor()
cursor.execute(sql)
cursor.close()