Skip to content

Commit

Permalink
Fix/bad sql argument (#36)
Browse files Browse the repository at this point in the history
* Replaced --sql with --query

* Added example for escaping backticks

---------

Co-authored-by: Ramin Haeri Azad <rhaeri@maelstrom-reseach.org>
  • Loading branch information
kazoompa and Ramin Haeri Azad committed Jun 9, 2023
1 parent dfb9ce9 commit 83523b8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python-user-guide/datasources/sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,28 @@ Simple SQL query with CSV output:

.. code-block:: bash
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --project CNSIM --sql "select * from CNSIM1 limit 10"
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --project CNSIM --query "select * from CNSIM1 limit 10"
Simple SQL query with JSON output:

.. code-block:: bash
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --project CNSIM --sql "select * from CNSIM1 limit 10" --format json
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --project CNSIM --query "select * from CNSIM1 limit 10" --format json
More advanced SQL query:

.. code-block:: bash
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --project CNSIM --sql "select count(*) as N, avg(LAB_HDL) as HDL_AVG, GENDER from (select * from CNSIM1 union all select * from CNSIM2) where LAB_HDL is not null group by GENDER"
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --project CNSIM --query "select count(*) as N, avg(LAB_HDL) as HDL_AVG, GENDER from (select * from CNSIM1 union all select * from CNSIM2) where LAB_HDL is not null group by GENDER"
Simple SQL query with CSV output and without specifying a project in the arguments:

.. code-block:: bash
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --sql "select * from `CNSIM.CNSIM1` limit 10"
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --query "select * from `CNSIM.CNSIM1` limit 10"
You can also escape the backticks (`) when executing from a Linux terminal (Bash)

.. code-block:: bash
opal sql --opal https://opal-demo.obiba.org --user administrator --password password --query "select * from \`CNSIM.CNSIM1\` limit 10"

0 comments on commit 83523b8

Please sign in to comment.