⚙️ Setup & Configuration :
Most of documentation pertaining to general configuration for
sqler-odbccan be found in thesqlermanual.
The following modules versions are required when using sqler-odbc:
{
"sqler": "^5.12.2",
"odbc": "^2.3.0"
}
Install the required modules:
npm install sqler
npm install sqler-odbc
npm install odbc
Connection and execution option extensions can be found under the API docs for globals.
📅 ODBC ANSI Date/Time
Due to the nature of ODBC, dates may need to be formatted to/from string values according to ANSI standards noted below.
| Notation | Description | |
|---|---|---|
| YYYY | 4-digit year | |
| MM | 2-digit month (01 to 12) | |
| DD | 2-digit day (01 to 31) | |
| HH | 2-digit hour (00 to 23) | |
| MI | 2-digit minute (00 to 59) | |
| SS | 2-digit second (00 to 59) | |
| FFF | Fraction of a second (1 to 9 digits) | |
| TH | 2-digit hour offset (-12 to 14) | |
| TM | 2-digit minute offset (00 to 59) | |
| YEARS | Number of years (max of 9999) | |
| DAYS | Number of days (max of 3652047) |
Using the forementioned notation, the following data types can be used on ODBC dates:
| Data Type | Format | Example |
|---|---|---|
| DATE | YYYY-MM-DD |
2030-01-31 |
| TIME (w/o timezone) | HH:MI:SS.FFF |
12:01:20.903 |
| TIME (with timezone) | HH:MI:SS.FFF [+|-]TH:TM |
12:01:20.903 -07:00 |
| TIMESTAMP (w/o timezone) | YYYY-MM-DD HH:MI:SS.FFF |
2030-01-31 12:01:20.903 |
| TIMESTAMP (with timezone) | YYYY-MM-DD HH:MI:SS.FFF [+|-]TH:TM |
2030-01-31 12:01:20.903 -07:00 |
| INTERVAL YEAR TO MONTH | [+|-]YEARS-MM |
+130-01 |
| INTERVAL DAY TO SECONDS | [+|-]DAYS HH:MI:SS.FFF |
-47482 12:01:20.903 |
NOTE: The
moment-dbmodule can be used to assist with ANSI compatible database date formatting
💡 Examples:
Although, sqler-odbc can be used with any ODBC compliant database driver, below illustrates the use with some popular implementations