diff options
Diffstat (limited to 'lib/output/pq')
-rw-r--r-- | lib/output/pq/updateDatabase.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/output/pq/updateDatabase.cpp b/lib/output/pq/updateDatabase.cpp index 457f744..907ee60 100644 --- a/lib/output/pq/updateDatabase.cpp +++ b/lib/output/pq/updateDatabase.cpp @@ -185,13 +185,16 @@ namespace MyGrate::Output::Pq { UpdateDatabase::copyTableContent(Input::MySQLConn * conn, const char * table) { auto out = beginBulkUpload(schema.c_str(), table); - std::stringstream sf; - unsigned int ordinal {0}; - for (const auto & col : tables.at(table)->columns) { - scprintf<"%? %?">(sf, !ordinal++ ? "SELECT " : ", ", col->name); - } - sf << " FROM " << table; - auto stmt {conn->prepare(sf.str().c_str(), 0)}; + auto sourceSelect = [this](auto table) { + std::stringstream sf; + unsigned int ordinal {0}; + for (const auto & col : tables.at(table)->columns) { + scprintf<"%? %?">(sf, !ordinal++ ? "SELECT " : ", ", col->name); + } + sf << " FROM " << table; + return sf.str(); + }; + auto stmt {conn->prepare(sourceSelect(table).c_str(), 0)}; stmt->execute({}); auto sourceCursor {stmt->cursor()}; |