Move pgwui_core SQL related code into it's own module
authorKarl O. Pinc <kop@karlpinc.com>
Sat, 14 Sep 2024 03:22:06 +0000 (22:22 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Sat, 14 Sep 2024 03:22:06 +0000 (22:22 -0500)
src/pgwui_copy/views/copy.py

index 86436fcf7214d4f4f73cdf5bf185566f68372007..2a704f6db1e40358570592d67a807c26bcf5838f 100644 (file)
@@ -35,15 +35,13 @@ from wtforms import (
 from pyramid.view import view_config
 
 import pgwui_core.forms
+import pgwui_core.sql
 import pgwui_core.utils
 from pgwui_core.core import (
     UploadEngine,
     NoTransactionEngine,
     SessionDBHandler,
-    LogSQLCommand,
-    SQLData,
     NoOpProcessor,
-    ExecuteSQL,
 )
 
 from pgwui_core.exceptions import AuthFailError
@@ -203,7 +201,7 @@ class CopySchemaHandler(SessionDBHandler):
         Side Effects:
         Yes, lots.
         '''
-        return ExecuteSQL(ue, self)
+        return pgwui_core.sql.ExecuteSQL(ue, self)
 
     def render(self, errors, result):
         '''Instead of rendering, just our results so we can
@@ -407,7 +405,7 @@ class DropSchemaHandler(CopySchemaHandler):
         to_db = uf['to_db']
 
         # Drop the schema
-        sql.append(LogSQLCommand(
+        sql.append(pgwui_core.sql.LogSQLCommand(
             'DROP SCHEMA {0} CASCADE'.format(schema),
             (),
             lambda ex: copy_ex.DropSchemaError(ex, schema, to_db),
@@ -415,14 +413,14 @@ class DropSchemaHandler(CopySchemaHandler):
             log_failure=self.log_dropschema_failure))
 
         # Vacuum the target db
-        sql.append(LogSQLCommand(
+        sql.append(pgwui_core.sql.LogSQLCommand(
             'VACUUM FULL',
             (),
             lambda ex: copy_ex.VacuumFullError(ex, to_db),
             log_success=self.log_vacuumfull_success,
             log_failure=self.log_vacuumfull_failure))
 
-        self.data = SQLData(sql)
+        self.data = pgwui_core.sql.SQLData(sql)
 
 
 class VacuumHandler(CopySchemaHandler):
@@ -449,14 +447,14 @@ class VacuumHandler(CopySchemaHandler):
         to_db = uf['to_db']
 
         # Vacuum the target db
-        sql.append(LogSQLCommand(
+        sql.append(pgwui_core.sql.LogSQLCommand(
             'VACUUM ANALYZE',
             (),
             lambda ex: copy_ex.VacuumAnalyzeError(ex, to_db),
             log_success=self.log_vacuumanalyze_success,
             log_failure=self.log_vacuumanalyze_failure))
 
-        self.data = SQLData(sql)
+        self.data = pgwui_core.sql.SQLData(sql)
 
 
 class CheckFromSchemaEngine(UploadEngine):