| 142 | === Basics === |
| 143 | |
| 144 | Let's try our previous example |
| 145 | {{{ |
| 146 | fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!'" |
| 147 | [...] |
| 148 | ------------------------ Rootify SQL ------------------------- |
| 149 | [...] |
| 150 | Opening file 'rootify.root' [compression=1]... |
| 151 | Writing data to tree 'Result' |
| 152 | Trying to setup 1 branches... |
| 153 | |
| 154 | - Hello World! [VARCHAR NOT NULL] {V} |
| 155 | |
| 156 | Configured 0 branches. |
| 157 | Filling branches... |
| 158 | 1 rows fetched. |
| 159 | 1 rows filled into tree. |
| 160 | 4 kB written to disk. |
| 161 | File closed. |
| 162 | Execution time: 0.0775619s (77.6 ms/row) |
| 163 | -------------------------------------------------------------- |
| 164 | }}} |
| 165 | |
| 166 | The option {{{-f}}} (which is a shortcut for {{{--force}}}) actually overwrites an existing root file (''RECREATE''). The verbosity option {{{-v 2}}} prints some information on how the table columns are translated. As the output suggests, 1 branch could have been setup (one column was returned), but no branch was configured. Our "''Hello World!''" string is returned as a VARCHAR (or CHAR), but only values are supported. The leading {{{-}}} tells us that the column was skipped, the {{{V}}} is an internal abbreviation for the action (and {{{C}}} for {{{CHAR}}}). So second try: |
| 167 | |
| 168 | {{{ |
| 169 | fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1" |
| 170 | [...] |
| 171 | ------------------------ Rootify SQL ------------------------- |
| 172 | [...] |
| 173 | Opening file 'rootify.root' [compression=1]... |
| 174 | Writing data to tree 'Result' |
| 175 | Trying to setup 2 branches... |
| 176 | |
| 177 | - Hello World! [VARCHAR NOT NULL] {V} |
| 178 | + 1 [BIGINT NOT NULL] {n} |
| 179 | |
| 180 | Configured 1 branches. |
| 181 | Filling branches... |
| 182 | 1 rows fetched. |
| 183 | 1 rows filled into tree. |
| 184 | 5 kB written to disk. |
| 185 | File closed. |
| 186 | Execution time: 0.064065s (64.1 ms/row) |
| 187 | -------------------------------------------------------------- |
| 188 | }}} |
| 189 | |
| 190 | Now one branch was setup successfully (indicated by the {{{+}}}) because it of a basic (numerical) type (indicated by the {{{n}}}). |
| 191 | |
| 192 | All columns of a numerical type ({{{n}}}) get converted to a branch of type double in the root-file. This keeps reading the root-file simple. All SQL columns of types {{{DATE}}}, {{{DATETIME}}} and {{{TIME}}} are converted to UNIX time and also written as a double-branch. |
| 193 | |
| 194 | To have another way to skip columns, all variables defined in a query are skipped: |
| 195 | {{{ |
| 196 | fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1, @a:=5" |
| 197 | [...] |
| 198 | ------------------------ Rootify SQL ------------------------- |
| 199 | [...] |
| 200 | Trying to setup 3 branches... |
| 201 | |
| 202 | - Hello World! [VARCHAR NOT NULL] {V} |
| 203 | + 1 [BIGINT NOT NULL] {n} |
| 204 | - @a:=5 [BIGINT NOT NULL] {@} |
| 205 | |
| 206 | 1 branches skipped due to name starting with @. |
| 207 | Configured 1 branches. |
| 208 | [...] |
| 209 | -------------------------------------------------------------- |
| 210 | }}} |
| 211 | |
| 212 | This can be circumvented by giving it a name |
| 213 | {{{ |
| 214 | fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1, @a:=5 AS MyName" |
| 215 | [...] |
| 216 | ------------------------ Rootify SQL ------------------------- |
| 217 | [...] |
| 218 | Trying to setup 3 branches... |
| 219 | |
| 220 | - Hello World! [VARCHAR NOT NULL] {V} |
| 221 | + 1 [BIGINT NOT NULL] {n} |
| 222 | + MyName [BIGINT NOT NULL] {n} |
| 223 | |
| 224 | Configured 2 branches. |
| 225 | [...] |
| 226 | -------------------------------------------------------------- |
| 227 | }}} |
| 228 | |
| 229 | Usually the name of the root-branch coincides with the name of the column, but it can easily be overwritten in the query with the {{{AS}}} directive as illustrated above. |
| 230 | |
| 231 | Now assuming you want to create a very general query but then skip some column in the root-file (usually, it is more efficient to just don't query them, because they are transferred from the server nevertheless). In this case you can do: |
| 232 | {{{ |
| 233 | fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1, @a:=5 AS MyName" --ignore MyName |
| 234 | [...] |
| 235 | ------------------------ Rootify SQL ------------------------- |
| 236 | [...] |
| 237 | Trying to setup 3 branches... |
| 238 | |
| 239 | - Hello World! [VARCHAR NOT NULL] {V} |
| 240 | + 1 [BIGINT NOT NULL] {n} |
| 241 | - MyName [BIGINT NOT NULL] {-} |
| 242 | |
| 243 | 1 branches skipped due to ignore list. |
| 244 | Configured 1 branches. |
| 245 | [...] |
| 246 | -------------------------------------------------------------- |
| 247 | }}} |
| 248 | |
| 249 | The {{{--ignore}}} option can be specified more than once and it takes regular expression. So {{{--ignore M.*}}} would skip all columns starting with '''My'''. |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |