author | František Kučera <franta-hg@frantovo.cz> |
Fri, 25 Oct 2019 12:33:00 +0200 | |
branch | v_0 |
changeset 14 | eacacf060755 |
parent 12 | 0b38339b871b |
child 15 | 0ecde5272f8e |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* Relational pipes |
|
3 |
* Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
|
4 |
* |
|
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
10
7da7173d84b0
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
7 |
* the Free Software Foundation, version 3. |
0 | 8 |
* |
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
#pragma once |
|
18 |
||
19 |
#include <relpipe/writer/AttributeMetadata.h> |
|
20 |
#include <relpipe/writer/typedefs.h> |
|
21 |
||
22 |
namespace relpipe { |
|
23 |
namespace tr { |
|
24 |
namespace sql { |
|
25 |
||
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
26 |
class Parameter { |
0 | 27 |
public: |
28 |
||
29 |
relpipe::writer::string_t value; |
|
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
30 |
// TODO: relpipe::writer::TypeId type; |
0 | 31 |
}; |
32 |
||
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
33 |
class Statement { |
0 | 34 |
public: |
35 |
||
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
36 |
virtual ~Statement() { |
0 | 37 |
} |
38 |
||
39 |
/** |
|
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
40 |
* output relation name; |
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
41 |
* if empty, the SQL code (DML, DDL) will be executed, but no relational output will be generated |
0 | 42 |
*/ |
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
43 |
relpipe::writer::string_t relation; |
0 | 44 |
/** |
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
45 |
* SQL code, usually some SELECT; |
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
46 |
* might be also DML or DDL |
0 | 47 |
*/ |
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
48 |
relpipe::writer::string_t sql; |
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
49 |
std::vector<Parameter> parameters; |
0 | 50 |
}; |
51 |
||
12
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
52 |
enum class KeepFile { |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
53 |
/** The file will be kept even if it was created during this transformation, so all the input data will stay on the disk. */ |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
54 |
Always, |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
55 |
/** The file will be deleted at the end of this transformation – even if the file already existed. This is potentially dangerous, because we can unintentionally delete a database file. */ |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
56 |
Never, |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
57 |
/** The file will be kept only if it was already present before the transformation. */ |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
58 |
Automatic |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
59 |
}; |
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
60 |
|
0 | 61 |
class Configuration { |
62 |
public: |
|
63 |
||
5
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
64 |
|
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
65 |
/** |
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
66 |
* By default, this transformation runs in-memory. |
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
67 |
* If 'file' is not empty, this transformation will operate on an .sqlite file. |
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
68 |
* The file will be created if it does not exist. |
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
69 |
*/ |
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
70 |
relpipe::writer::string_t file; |
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
71 |
|
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
72 |
/** |
12
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
73 |
* see KeepFile documentation |
5
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
74 |
*/ |
12
0b38339b871b
improve --keep-file option: default is auto = file will be kept, if it was present before the transformation
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
75 |
KeepFile keepFile = KeepFile::Automatic; |
5
cbc7817a3346
add option to create DB in a file and to keep that file
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
76 |
|
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
77 |
std::vector<Statement> statements; |
14
eacacf060755
add --dump option: allow pass through of relation specified by a regular expression
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
78 |
|
eacacf060755
add --dump option: allow pass through of relation specified by a regular expression
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
79 |
std::wstring dumpRelations; |
0 | 80 |
|
81 |
virtual ~Configuration() { |
|
82 |
} |
|
83 |
}; |
|
84 |
||
85 |
} |
|
86 |
} |
|
2
362f2689cb87
configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
87 |
} |