sql2odata-cli
v0.0.3
Published
Translate SQL statements into OData v4 query syntax from the command line
Maintainers
Readme
sql2odata-cli
Translate SQL statements into OData v4 query syntax from the command line.
Install
npm install -g sql2odata-cliUsage
Usage: sql2odata [options] [sql...]
Translate SQL statements into OData v4 query syntax
Arguments:
sql SQL statement to translate
Options:
-e, --encode URL-encode the output
-j, --json Output as JSON (for scripting)
-c, --copy Copy result to clipboard
-i, --interactive Interactive REPL mode
-V, --version Show version
-h, --help Show helpExamples
Translate a SELECT query:
sql2odata "SELECT Name, Age FROM Users WHERE Country = 'Germany' ORDER BY Name LIMIT 10"URL-encoded output:
sql2odata -e "SELECT * FROM Products WHERE Name LIKE '%bike%' AND Price > 100"JSON output (for scripting):
sql2odata -j "INSERT INTO Products (Name, Price) VALUES ('Widget', 29.99)"Pipe from stdin:
echo "DELETE FROM Products WHERE ID = 42" | sql2odataInteractive REPL:
sql2odata -iSupported SQL
| SQL | OData v4 |
|-----|----------|
| SELECT col1, col2 | $select=col1,col2 |
| SELECT * | (all fields) |
| SELECT COUNT(*) | $count=true |
| FROM Table | /Table |
| WHERE col = 'val' | $filter=col eq 'val' |
| WHERE LIKE '%text%' | contains(col,'text') |
| WHERE IN ('a','b') | (col eq 'a' or col eq 'b') |
| WHERE BETWEEN 1 AND 10 | col ge 1 and col le 10 |
| IS NULL / IS NOT NULL | eq null / ne null |
| ORDER BY col ASC | $orderby=col asc |
| LIMIT n / OFFSET n | $top=n / $skip=n |
| JOIN Table ON ... | $expand=Table |
| GROUP BY + aggregates | $apply=groupby(...) |
| INSERT INTO ... VALUES | POST + JSON body |
| UPDATE ... SET ... WHERE | PATCH + JSON body |
| DELETE FROM ... WHERE | DELETE |
License
MIT
Author
Ulrich Waldmann — [email protected]
