This section outlines the use of the c8_client program to publish data to a stream.
To do this, use the "publish" command and specify several command-line parameters. We'll start with an example command and then explain each part of the command. The example is split across multiple lines for clarity, but when you use the command it must all be on one line.
Note that options are prefixed with two dashes, not one.
cat data.csv | ./c8_client --cmd=publish --format=csv --timestamp-mode=set-current --format-options='FieldDelimeterChars=^,TimestampColumn=false' --uri=ccl://hypatia:6901/Stream/Default/SimpleTest/instream
In this example,
The data format is Comma-Separated Values (CSV).
The Row Timestamp is based on the time that the row arrives, not on a Row Timestamp inside the row.
The field delimiter character (the character that separates fields within a row) is the caret character "^", rather than the comma ",".
The row does not contain a Row Timestamp column.
The c8_client program is ordered to write the data to the stream that has the stream URI ccl://hypatia:6901/Stream/Default/SimpleTest/instream.
The following table documents several of the command-line parameters, including the ones used in the example above. For a complete list of parameters that apply to your version of Sybase CEP Server, execute the following command:
c8_client --cmd=publish --help
Note that the command-line options are case-sensitive.
Parameter |
Description |
---|---|
format |
Must be one of the three Sybase CEP data stream formats: CSV (Comma-Separated Values), XML, binary. Note that the binary format is not documented, and we recommend that you use the CSV format. |
username |
The user name. Required if user authentication is enabled. |
password |
The password of the user you specified. Required only if a username has been specified. |
uri |
The URI of the stream you want to publish to. For instructions on obtaining the URI of a stream, see How to Find the URI of a Stream. |
timestamp-mode |
This value may be set to "as-is" or "set-current". If the value is "as-is", the server uses the row timestamp in the data. If the value is "set-current", the server replaces the row timestamp with the current timestamp (as of the time that the row is received by the server). |
csv-title-row |
If set to true, the server treats the first row as a title row. If set to false, the server treats the first row as a row of data. |
csv-timestamp-column |
If this is set to true, the first row of data is treated as the Row Timestamp. If set to false, the data is treated as though it has no Row Timestamp. |
csv-timestamp-column-format |
If this value is set, the server assumes that the format of all timestamp columns, including the Row Timestamp (if present) matches this format. If this value is not set, the server assumes that all timestamp values, including the Row Timestamp (if present) are in the default format (microseconds since midnight January 1, 1970 GMT/UTC). Valid timestamp formats (such as "YYYY-MM-DD HH24:MI:SS.FF") are documented in the Sybase CEP CCL Reference Guide . |
When you use the "--format-options" command-line parameter, separate the options with commas and put quotation marks around the entire group of format options. On unix-like operating systems, the quotation marks can be single quotes or double quotes. On MS-Windows, the quotation marks must be double quotes.
For example:
cat data.csv | ./c8_client --cmd=publish ... --format-options= "FieldDelimeterChars=|,TimestampColumn=false"
In this example, we specify that the field delimiter character should be a vertical bar ("|") instead of a comma. We also specify that there is no Row Timestamp column.
The following table shows some of the options that you may use with the "format-options" command-line parameter.
Note that some format-options overlap some of the command-line parameters in the preceding table. For example, you may specify that the input has a title row by using either the format-option HaveTitleRow=true or by using the command-line parameter --csv-title-row=true. If there is more than one way to specify a particular behavior, use only one of those ways. If you specify conflicting behaviors with different options, the behavior of the product is undefined.
Note that the format options are case-sensitive.
Parameter |
Description |
---|---|
TitleRow |
Set this to true if the input contains a title row; set it to false otherwise. |
HaveTitleRow |
Set this to true if the input contains a title row; set it to false otherwise. This option is for backwards compatibility only; otherwise use TitleRow. |
TimestampColumn |
Set this to true if the first column of input is a Row Timestamp; set it to false otherwise. |
HaveTimestampColumn |
Set this to true if the first column of input is a Row Timestamp; set it to false otherwise. This option is for backwards compatibility only; otherwise, use TimestampColumn. |
TimestampColumnFormat |
The format in which timestamp values (including the Row Timestamp, if any) are stored, for example "YYYY-MM-DD HH24:MI:SS.FF". For a complete description of timestamp formats, see the Sybase CEP CCL Reference Guide . |
NullColumnValue |
An explicit string that represents a NULL value. For example, you may use the string "NULL" to represent NULL. An empty field (two field separators with nothing, except possibly whitespace, between them) will also be treated as NULL. |
LineDelimiterChars |
The character that terminates a line of CSV input (in other words, that terminates a row). The default character is a newline character. |
LineContinuationChars |
The character used to permit a line of CSV data to be continued to the next line. If this character is used, it must be the last character (except whitespace) on the line. |
FieldDelimiterChars |
The character used to separate columns of CSV data. The default value is a comma. |
QuoteChars |
The character(s) which may be used to quote CSV strings. By default, either a single quote character (') or a double quote character (") canbe used. Note that the entire string of format options must be enclosed in quotes, so you may need to use the escape character (backslash) to specify a quotation mark within the quoted string. For example, the following specifies that the single quote mark, double quote mark and the backquote character should all be treated as delimiters for STRING fields: --format-options="QuoteChars`\"'" , |
EscapeChars |
The character used to indicate that the immediately following character should be interpreted specially. |
WhitespaceChars |
This allows you to specify a different set of whitespace characters than the default. For example, if you want the tab character (ctrl-I) to be used as a field delimiter, then you do not want it to continue to be treated as a whitespace character. To accomplish this, you might create a set of whitespace characters that exclude the tab character. |
TrimWhitespaces |
If set to true, whitespace characters outside of quotes are trimmed from STRING fields. If this is set to false, whitespace characters are preserved. Whitespace characters inside quotation marks are always preserved. |