Skip to content

Azure CosmosDB command line client for SQL queries

Notifications You must be signed in to change notification settings

irymaruk/cosmosdb-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure CosmosDB command line client for SQL queries

Preconditions:

  1. mvn clean package
  2. Rename cosmosdb-cli-jar-with-dependencies.jar into cosmosdb-cli.jar and put along with config.properties into one folder
  3. Update uir and key in config.properties

Usage examples:

1 - show usage:

java -jar cosmosdb-cli.jar

CosmosDB command line client v 1.0
Place config.properties and cosmosdb-cli.jar to the same folder
Usage: java -jar cosmosdb-cli.jar [options]
  Options:
  * --database, -d
      Database name
  * --collection, -c
      Collection name
  * --sql, -s
      SQL string (in double quotes)
    --env, -e
      Environment prefix. If not specified then default.env.prefix from 
      config.properties will be used
    --format, -f
      Output format JSON or CSV (default JSON)
      Default: JSON
    --help, -h
      Show usage

Examples:
java -jar cosmosdb-cli.jar --database rxr-rxi-dev-purchaseordermanagement --collection POM_Product --sql "SELECT top 2 c.productCode FROM POM_Product as c"
java -jar cosmosdb-cli.jar -f csv -e devqe -d rxr-rxi-devqe-purchaseordermanagement -c POM_Product -s "SELECT top 2 c.productCode, c.productCoding.upc, c.drugClassFederal, c.itemDescription FROM POM_Product as c"

Output

SQL result will be print to the console. Program logs will be stored in the file cosmosdb-cli.log

Example 1 (json)

[ {
    "productCode" : "11183",
    "drugClassFederal" : "NA",
    "itemDescription" : "HYDROCO-APAP 5/325MG TAB(TRI)1000"
}, {
    "productCode" : "16293",
    "drugClassFederal" : "NA",
    "itemDescription" : "PROGESTERONE 200MG CAPS (DR)100"
} ]

Example 2 (csv)

productCode,drugClassFederal,itemDescription
11183,NA,"HYDROCO-APAP 5/325MG TAB(TRI)1000"
16293,NA,"PROGESTERONE 200MG CAPS (DR)100"

About

Azure CosmosDB command line client for SQL queries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages