1 /*
2 BAREOS® - Backup Archiving REcovery Open Sourced
3
4 Copyright (C) 2020-2020 Bareos GmbH & Co. KG
5
6 This program is Free Software; you can redistribute it and/or
7 modify it under the terms of version three of the GNU Affero General Public
8 License as published by the Free Software Foundation and included
9 in the file LICENSE.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Affero General Public License for more details.
15
16 You should have received a copy of the GNU Affero General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
20 */
21
22 #include "include/bareos.h"
23 #include "dird/dbcopy/database_connection.h"
24 #include "dird/dbcopy/database_import.h"
25 #include "dird/dbcopy/database_import_mysql.h"
26 #include "dird/dbcopy/database_table_descriptions.h"
27
DatabaseImport(const DatabaseConnection & db_connection)28 DatabaseImport::DatabaseImport(const DatabaseConnection& db_connection)
29 : db_(db_connection.db)
30 , table_descriptions_(DatabaseTableDescriptions::Create(db_connection))
31 {
32 return;
33 }
34
35 DatabaseImport::~DatabaseImport() = default;
36
Create(const DatabaseConnection & db_connection,std::size_t maximum_amount_of_rows)37 std::unique_ptr<DatabaseImport> DatabaseImport::Create(
38 const DatabaseConnection& db_connection,
39 std::size_t maximum_amount_of_rows)
40 {
41 switch (db_connection.db_type) {
42 case DatabaseType::Enum::kMysql:
43 return std::make_unique<DatabaseImportMysql>(db_connection,
44 maximum_amount_of_rows);
45 default:
46 case DatabaseType::Enum::kPostgresql:
47 throw std::runtime_error(
48 "DatabaseImport: Database type unknown or not implemented");
49 }
50 }
51