From 318fe4984c30f7589cea91580a831090e78b3689 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Sat, 23 Aug 2014 12:20:02 +0300 Subject: [PATCH] Refactor operations - Make copy_database use new template parameter of create_database function - Update SA-Utils dependency to 0.26.13 --- requirements.txt | 2 +- stellar/operations.py | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index c0e6d6d..1221c27 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ pytest==2.5.2 schema==0.3.1 psutil==2.1.1 click==3.1 -SQLAlchemy-Utils==0.26.11 +SQLAlchemy-Utils==0.26.13 diff --git a/stellar/operations.py b/stellar/operations.py index 47018f8..f0b1a72 100644 --- a/stellar/operations.py +++ b/stellar/operations.py @@ -36,14 +36,9 @@ def copy_database(raw_conn, from_database, to_database): terminate_database_connections(raw_conn, from_database) if raw_conn.engine.dialect.name == 'postgresql': - raw_conn.execute( - ''' - CREATE DATABASE "%s" WITH TEMPLATE "%s"; - ''' % - ( - to_database, - from_database - ) + sqlalchemy_utils.functions.create_database( + '%s%s' % (raw_conn.engine.url, to_database), + template=from_database ) elif raw_conn.engine.dialect.name == 'mysql': # Horribly slow implementation.