htsql-tutorial / test / output / routine.yaml

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
#
# This file contains expected test output data for regression tests.
# It was generated automatically by the `regress` routine.
#

id: routine
tests:
- id: htsql-ctl
  tests:
  - ctl: []
    stdout: |
      HTSQL-CTL - HTSQL command-line administrative application
      Copyright (c) 2006-2012, Prometheus Research, LLC

      Run `htsql-ctl help` for general usage and list of routines.
      Run `htsql-ctl help <routine>` for help on a specific routine.
    exit: 0
  - ctl: [--help]
    stdout: |+
      HTSQL-CTL - HTSQL command-line administrative application
      Copyright (c) 2006-2012, Prometheus Research, LLC
      Usage: htsql-ctl <routine> [options] [arguments]

      Run `htsql-ctl help` for general usage and list of routines.
      Run `htsql-ctl help <routine>` for help on a specific routine.

      Available routines:
        extension (ext)          : list and describe HTSQL extensions
        help (h, ?)              : describe the usage of the application and its routines
        regress (test)           : run regression tests
        server (serve, s)        : start an HTTP server handling HTSQL requests
        shell (sh)               : start an HTSQL shell
        ui                       : start a visual HTSQL browser
        version                  : display the version of the application

    exit: 0
  - ctl: [--version]
    stdout: |+
      HTSQL 2.3.1.dev
      Copyright (c) 2006-2012, Prometheus Research, LLC

      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.  This software
      is released under the AGPLv3 as well as a permissive license for use
      with open source databases.  See http://htsql.org/license/.

      The HTSQL language and implementation were developed by members
      of the HTSQL Project (http://htsql.org/).

    exit: 0
- id: htsql-ctl-help
  tests:
  - ctl: [help, help]
    stdout: |+
      HELP - describe the usage of the application and its routines
      Usage: htsql-ctl help [ROUTINE [FEATURE]]

      Run 'htsql-ctl help' to describe the usage of the application and
      get the list of available routines.

      Run 'htsql-ctl help <routine>' to describe the usage of the
      specified routine.

      Some routines may contain separate descriptions of some features.
      Run 'htsql-ctl help <routine> <feature>' to describe a specific
      feature.

      Arguments:
        ROUTINE                  : the name of the routine to describe
        FEATURE                  : the feature to describe

    exit: 0
  - ctl: [help]
    stdout: |+
      HTSQL-CTL - HTSQL command-line administrative application
      Copyright (c) 2006-2012, Prometheus Research, LLC
      Usage: htsql-ctl <routine> [options] [arguments]

      Run `htsql-ctl help` for general usage and list of routines.
      Run `htsql-ctl help <routine>` for help on a specific routine.

      Available routines:
        extension (ext)          : list and describe HTSQL extensions
        help (h, ?)              : describe the usage of the application and its routines
        regress (test)           : run regression tests
        server (serve, s)        : start an HTTP server handling HTSQL requests
        shell (sh)               : start an HTSQL shell
        ui                       : start a visual HTSQL browser
        version                  : display the version of the application

    exit: 0
- id: htsql-ctl-version
  tests:
  - ctl: [help, version]
    stdout: |+
      VERSION - display the version of the application
      Usage: htsql-ctl version

      Run 'htsql-ctl version' to display the version of HTSQL.

    exit: 0
  - ctl: [version]
    stdout: |+
      HTSQL 2.3.1.dev
      Copyright (c) 2006-2012, Prometheus Research, LLC

      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.  This software
      is released under the AGPLv3 as well as a permissive license for use
      with open source databases.  See http://htsql.org/license/.

      The HTSQL language and implementation were developed by members
      of the HTSQL Project (http://htsql.org/).

    exit: 0
- id: htsql-ctl-shell
  tests:
  - ctl: [help, shell]
    stdout: |+
      SHELL - start an HTSQL shell
      Usage: htsql-ctl shell [DB]

      The routine starts an interactive HTSQL shell over the specified database.

      The DB argument specifies database connection parameters; must have the
      form:

          engine://username:password@host:port/database

      Here,

        - ENGINE is the type of the database server; supported values are
          `sqlite`, `pgsql`, `mysql`, `mssql` and `oracle`.
        - The parameters USERNAME:PASSWORD are used for authentication.
        - The parameters HOST:PORT indicate the address of the database
          server.
        - DATABASE is the name of the database; for SQLite, the path to the
          database file.

      All parameters except ENGINE and DATABASE are optional.

      When the shell is started, you will see the shell prompt with the
      database name followed by `$`.  Type an HTSQL query and press ENTER to
      execute it.  Type a command with any arguments and press ENTER to
      execute the command.  In particular, use `help` to get a list of shell
      commands, `help <command>` to describe a command.

      Type `exit` or Ctrl-D to exit the shell.

      Shell commands: (run 'htsql-ctl help shell <command>' for more help)
        help [command]           : describe the shell or a shell command
        version                  : print version and license information
        exit                     : quit the shell
        user [remote_user]       : set the remote user for HTTP requests
        describe [table]         : list tables, or slots for a given table
        headers on|off           : display HTTP status line and headers
        pager on|off             : pipe long output to a pager
        [get] /query             : execute an HTSQL query
        post /query              : execute an HTSQL query with POST data
        run filename.htsql       : run an HTSQL query from a file

      Arguments:
        DB                       : the connection URI

      Valid options:
        -p [--password]          : ask for the database password
        -E [--extension] EXT [+] : include extra extensions
        -C [--config] FILE       : read HTSQL configuration from FILE

    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |+
      /count(school)
       | count(school) |
      -+---------------+-
       |             9 |

    exit: 0
  - ctl: [shell, -E, 'htsql:db=''sqlite:build/regress/sqlite/htsql_demo.sqlite''']
    stdout: |+
      /count(school)
       | count(school) |
      -+---------------+-
       |             9 |

    exit: 0
  - ctl: [shell, -C, build/regress/sqlite/htsql_demo.yaml]
    stdout: |+
      /count(school)
       | count(school) |
      -+---------------+-
       |             9 |

    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite', -E, 'htsql:debug=true',
      -E, tweak.meta]
    stdout: |
      /meta(/count(table))
       | count(table) |
      -+--------------+-
       |           15 |

       ----
       /count(table)
       SELECT "table"."count"
       FROM (SELECT COUNT(1) AS "count"
             FROM "table") AS "table"
       WHERE ("table"."count" IS NOT NULL)
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite', -E, 'htsql:debug=false',
      -E, 'htsql:debug=true']
    stdout: |+
      /count(school)
       | count(school) |
      -+---------------+-
       |             9 |

    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help help
      HELP - describe the shell or a shell command
      Usage: help [command]

      Type `help` to learn how to use the shell and to get a list of available
      commands.

      Type `help <command>` to learn how to use the specified command.

      help
      To execute an HTSQL query, type

          /query

      To execute a shell command, type

          command [arguments...]

      Available commands:
        help [command]           : describe the shell or a shell command
        version                  : print version and license information
        exit                     : quit the shell
        user [remote_user]       : set the remote user for HTTP requests
        describe [table]         : list tables, or slots for a given table
        headers on|off           : display HTTP status line and headers
        pager on|off             : pipe long output to a pager
        [get] /query             : execute an HTSQL query
        post /query              : execute an HTSQL query with POST data
        run filename.htsql       : run an HTSQL query from a file

      help error
      ** unknown command 'error'
      error
      ** unknown command 'error'
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |+
      help version
      VERSION - print version and license information
      Usage: version

      Type `version` to list the current software version and
      license information.

      version
      HTSQL 2.3.1.dev
      Copyright (c) 2006-2012, Prometheus Research, LLC

      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.  This software
      is released under the AGPLv3 as well as a permissive license for use
      with open source databases.  See http://htsql.org/license/.

      The HTSQL language and implementation were developed by members
      of the HTSQL Project (http://htsql.org/).

    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help exit
      EXIT - quit the shell
      Usage: exit

      Type `exit` or Ctrl-D to quit the shell.

      exit
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help user
      USER - set the remote user for HTTP requests
      Usage: user [remote_user]

      To set the remote user for HTTP requests, type `user <name>`.

      To unset the remote user for HTTP requests, type `user`.

      user
      ** remote user is unset
      user htsql_demo
      ** remote user is set to 'htsql_demo'
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: "help describe\nDESCRIBE - list tables, or slots for a given table\nUsage:
      describe [table]\n\nType `describe` to list all tables or `describe <table>`
      to list\nall columns and links for a given table.\n\ndescribe\nTables introspected
      for this database are:\n\tappointment\n\tclass\n\tclassification\n\tconfidential\n\tcourse\n\tcourse_classification\n\tdepartment\n\tenrollment\n\tinstructor\n\tprerequisite\n\tprogram\n\tprogram_requirement\n\tschool\n\tsemester\n\tstudent\n\ndescribe
      school\nSlots for `school` are:\n\t code       string\n\t name       string\n\t
      campus     string\n\t department PLURAL(department)\n\t program    PLURAL(program)\n\ndescribe
      school.code\nUnable to find table: school.code\n\ndescribe error\nUnable to
      find table: error\n\n"
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: "help headers\nHEADERS - display HTTP status line and headers\nUsage:
      headers on|off\n\nType `headers on` to enable output of HTTP status line and
      headers along\nwith any HTTP response body.\n\nType `headers off` to disable
      output of HTTP status line and headers.\nOnly HTTP response body will be displayed.\n\nheaders\n**
      expected 'on' or 'off'\nheaders on\n** headers are turned on\n/count(school)\n200
      OK\r\nContent-Type: text/plain; charset=UTF-8\r\nVary: Accept\r\n\r\n | count(school)
      |\n-+---------------+-\n |             9 |\n\nheaders off\n** headers are turned
      off\n/count(school)\n | count(school) |\n-+---------------+-\n |             9
      |\n\n"
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help pager
      PAGER - pipe long output to a pager
      Usage: pager on|off

      Type `pager on` or `pager off` to enable or disable the pager
      respectively.

      If the pager is enabled, and the number of lines in the HTTP response
      exceeds the height of the terminal, the response is displayed via the
      pager.

      The pager is a command which allows you to scroll and search in the
      output.  The pager application is determined by the environment variable
      $PAGER.  When $PAGER is not set, one of the common pagers such as
      `/usr/bin/more` is used if available.  The pager could only be enabled
      when the shell is running in a terminal.

      pager
      ** expected 'on' or 'off'
      pager on
      ** pager cannot be enabled in the non-interactive mode
      pager off
      ** pager is disabled
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help get
      GET - execute an HTSQL query
      Usage: [get] /query

      Type `get /query` or just `/query` to execute an HTSQL query.

      The output of the query is dumped to the console.  When the pager is
      enabled and the number of lines in the response body exceeds the height
      of the terminal, the output is displayed via the pager.  Use `pager off`
      to disable the pager.

      By default, the command does not dump the response status line and the
      headers.  To enable displaying the status line and the headers along
      with the response body, use `headers on`.

      get
      ** a query is expected
      get /count(school)
       | count(school) |
      -+---------------+-
       |             9 |

      /count(school)
       | count(school) |
      -+---------------+-
       |             9 |

      /error
      bind error: unrecognized attribute 'error':
          /error
           ^^^^^
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help post
      POST - execute an HTSQL query with POST data
      Usage: post /query

      Type `post /query` to execute an HTSQL query with POST data.

      You will be asked to provide a file containing the POST data and to
      indicate the content type of the data.

      The output of the query is dumped to the console.  When the pager is
      enabled and the number of lines in the response body exceeds the height
      of the terminal, the output is displayed via the pager.  Use `pager off`
      to disable the pager.

      By default, the command does not dump the response status line and the
      headers.  To enable displaying the status line and the headers along
      with the response body, use `headers on`.

      post
      ** a query is expected
      post /school
      build/regress/post.data
      application/x-www-form-urlencoded
      POST requests are not permitted.
      post /school
      error
      ** file 'error' does not exist
    exit: 0
  - ctl: [shell, 'sqlite:build/regress/sqlite/htsql_demo.sqlite']
    stdout: |
      help run
      RUN - run an HTSQL query from a file
      Usage: run filename.htsql

      Type `run filename.htsql` to load and execute an HTSQL query from a file.

      The command reads an HTSQL query from the given file and executes it as
      a GET request.

      The output of the query is dumped to the console.  When the pager is
      enabled and the number of lines in the response body exceeds the height
      of the terminal, the output is displayed via the pager.  Use `pager off`
      to disable the pager.

      By default, the command does not dump the response status line and the
      headers.  To enable displaying the status line and the headers along
      with the response body, use `headers on`.

      run
      ** a file name is expected
      run build/regress/run.htsql
       | count(school) | count(program) | count(department) |
      -+---------------+----------------+-------------------+-
       |             9 |             40 |                27 |

      run error
      ** file 'error' does not exist
    exit: 0
- id: htsql-ctl-server
  tests:
  - ctl: [help, server]
    stdout: |+
      SERVER - start an HTTP server handling HTSQL requests
      Usage: htsql-ctl server [DB]

      The routine starts an HTTP server that serves HTSQL requests over the
      specified database.

      The DB argument specifies database connection parameters; must have the
      form:

          engine://username:password@host:port/database

      Here,

        - ENGINE is the type of the database server; supported values are
          `sqlite`, `pgsql`, `mysql`, `mssql` and `oracle`.
        - The parameters USERNAME:PASSWORD are used for authentication.
        - The parameters HOST:PORT indicate the address of the database
          server.
        - DATABASE is the name of the database; for SQLite, the path to the
          database file.

      All parameters except ENGINE and DATABASE are optional.

      By default, the HTTP server listens on the port 8080 on all available
      interfaces.  Use options `--host` and `--port` to override the default
      values.

      The HTTP logs are dumped to the standard output in the Apache Common Log
      Format.  Use option `--quiet` to suppress the logs.

      Arguments:
        DB                       : the connection URI

      Valid options:
        -p [--password]          : ask for the database password
        -E [--extension] EXT [+] : include extra extensions
        -C [--config] FILE       : read HTSQL configuration from FILE
        --host HOST              : host to listen for incoming connections
        --port PORT              : port to listen for incoming connections
        -q [--quiet]             : display as little as possible

    exit: 0
  - py: GET-1
    stdout: |2+
       | count(school) |
      -+---------------+-
       |             9 |


  - end-ctl: [server, 'sqlite:build/regress/sqlite/htsql_demo.sqlite', -q]
    stdout: ''
  - py: GET-2
    stdout: |2+
       | count(school) |
      -+---------------+-
       |             9 |


  - end-ctl: [server, 'sqlite:build/regress/sqlite/htsql_demo.sqlite', --host, 127.0.0.1,
      --port, '8088', -q]
    stdout: ''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.