Package: okcli
okcliMan Okcli for Oracle Database.An Oracle-DB command line client with auto-completion and syntax highlighting that emulates the functionality ofsqlplus.indexinstalluser guideusagefaqinstallInstallokclifrompypiwithpip.> sudo pip install okclior without sudo credentials> pip install --user okclidocumentationFor documentation and config options see theuser guideor typehelpfrom within the app.demousageUsage: okcli [OPTIONS] [SQLPLUS]

  An Oracle-DB terminal client with auto-completion and syntax highlighting.

  Examples:
    - okcli -u my_user -h my_host.com -D schema
    - okcli user/password@tns_name 
    - okcli user/password@tns_name -D schema 
    - okcli user/password@tns_name -e "query"
    - okcli user@tns_name -@ query_file.sql

Options:
  -h, --host TEXT         Host address of the database.
  -P, --port INTEGER      Port number to use for connection.
  -u, --user TEXT         User name to connect to the database.
  -p, --password TEXT     Password to connect to the database.
  -v, --version           Output okcli's version.
  -D, --database TEXT     Database to use.
  -R, --prompt TEXT       Prompt format (Default: "\t \u@\h:\d> ").
  -l, --logfile FILENAME  Log every query and its results to a file.
  --okclirc PATH         Location of okclirc file.
  --auto-vertical-output  Automatically switch to vertical output mode if the
                          result is wider than the terminal width.
  -t, --table             Display batch output in table format.
  --csv                   Display batch output in CSV format.
  --warn / --no-warn      Warn before running a destructive query.
  --login-path TEXT       Read this path from the login file.
  -e, --execute TEXT      Execute command and quit.
  -@, --filename TEXT     Execute commands in a file.
  --help                  Show this message and exit.user-guidedisplay help textapp configset colour schemeexecute host shell commandsexecute commands from filedescribestored proceduresfavourite commandsescape to an editor to finish writing an SQL statementchange output formatlist all schemas in databaselist all tables in  a schemaspool (append) query output to a fileexit the apphelpThehelpcommand displays help text for all other commands.configThe file~/.okclircis created upon installation with config for okcli.Things like colour-scheme, prompt-format, log-file location etc. can be updated there.coloursThesyntax_styleparameter in theconfig-filesets the syntax colour scheme, select from the following:# Syntax coloring style. Possible values (many support the "-dark" suffix):
# manni, igor, xcode, vim, autumn, vs, rrt, native, perldoc, borland, tango, emacs,
# friendly, monokai, paraiso, colorful, murphy, bw, pastie, paraiso, trac, default,
# fruity.Other style options (eg. the status bar) can also be set in theconfig-file.shellStart a statement with!to execute it as a shell command.For exampleOracle-18c oracle@system:hr> ! echo Hello Okcli
Hello Okcliexec-fileExecute sql statements from a file by passing it as an argument with-@.For example:> cat date_query.sql 
select sysdate from dual
 > okcli hr@xe:HR -@date_query.sql
SYSDATE
2019-03-12 16:42:34describeThedescribecommand will show for a given table or view:each column, its datatype, if it's nullableprimary-key constraints (if it's a table)foreign-key constraints (if it's a view)the SQL query used to create the view (if it's a view)For example:Oracle-11g hr@xe:HR> desc HR.EMPLOYEES
+----------------+-----------+-------------+----------+
| COLUMN_NAME    | DATA_TYPE | DATA_LENGTH | NULLABLE |
+----------------+-----------+-------------+----------+
| EMPLOYEE_ID    | NUMBER    | 22          | N        |
| FIRST_NAME     | VARCHAR2  | 20          | Y        |
| LAST_NAME      | VARCHAR2  | 25          | N        |
| EMAIL          | VARCHAR2  | 25          | N        |
| PHONE_NUMBER   | VARCHAR2  | 20          | Y        |
| HIRE_DATE      | DATE      | 7           | N        |
| JOB_ID         | VARCHAR2  | 10          | N        |
| SALARY         | NUMBER    | 22          | Y        |
| COMMISSION_PCT | NUMBER    | 22          | Y        |
| MANAGER_ID     | NUMBER    | 22          | Y        |
| DEPARTMENT_ID  | NUMBER    | 22          | Y        |
+----------------+-----------+-------------+----------+
Time: 0.098s

+---------------------+
| PRIMARY_KEY_COLUMNS |
+---------------------+
| EMPLOYEE_ID         |
+---------------------+
Time: 0.370s

+---------------+---------------------------+
| COLUMN_NAME   | FOREIGN_KEY_CONSTRAINT    |
+---------------+---------------------------+
| DEPARTMENT_ID | DEPARTMENTS.DEPARTMENT_ID |
| JOB_ID        | JOBS.JOB_ID               |
| MANAGER_ID    | EMPLOYEES.EMPLOYEE_ID     |
+---------------+---------------------------+
Time: 2.228sstored-proceduresStored-procedures can be run with theexeccommand.For exampleOracle-11g hr@xe:HR> exec some_schema.my_procedure(arg1, 'arg2')favourite-commandsThe\fs [name]command will save the current statement with a name.The\f [name]command will load the statement with that name or list all the saved statements if no  name is given.The\fd [name]command will delete the saved statement.For exampleOracle-11g hr@xe:HR> \fs depts select  * from HR.DEPARTMENTS where MANAGER_ID > 200                                                                           
Saved.                                                                                                                                                        
Time: 0.003s                                                                                                                                                  
Oracle-11g hr@xe:HR> \f depts                                                                                                                                 
> select  * from HR.DEPARTMENTS where MANAGER_ID > 200                                                                                                        
+---------------+------------------+------------+-------------+
| DEPARTMENT_ID | DEPARTMENT_NAME  | MANAGER_ID | LOCATION_ID |
+---------------+------------------+------------+-------------+
| 20            | Marketing        | 201        | 1800        |
| 40            | Human Resources  | 203        | 2400        |
| 70            | Public Relations | 204        | 2700        |
| 110           | Accounting       | 205        | 1700        |
+---------------+------------------+------------+-------------+
4 row s in set
Time: 0.002s
Oracle-11g hr@xe:HR> \f
+-------+------------------------------------------------------+
| Name  | Query                                                |
+-------+------------------------------------------------------+
| depts | select  * from HR.DEPARTMENTS where MANAGER_ID > 200 |
+-------+------------------------------------------------------+
Time: 0.001s

No favorite query:
Time: 0.000s
Oracle-11g hr@xe:HR> \fs depts_2 select  * from HR.DEPARTMENTS where MANAGER_ID < 200
Saved.
Time: 0.001s
Oracle-11g hr@xe:HR> \f
+---------+------------------------------------------------------+
| Name    | Query                                                |
+---------+------------------------------------------------------+
| depts   | select  * from HR.DEPARTMENTS where MANAGER_ID > 200 |
| depts_2 | select  * from HR.DEPARTMENTS where MANAGER_ID < 200 |
+---------+------------------------------------------------------+
Time: 0.001seditWhen writing a statement you can escape to your favourite editor (set by$EDITOR) by addingedto the start of the query.When you save and exit the file it will take you back to the CLI with the statement that you finished  editing in the file.For example:Oracle-11g hr@xe:HR> ed select * fromformatTheformatcommand sets the format of the query-output (if there is any).The supported output formats are:jira                                                                                                                                                  
        latex                                                                                                                                                 
        github                                                                                                                                                
        latex_booktabs                                                                                                                                        
        vertical                                                                                                                                              
        simple                                                                                                                                                
        plain                                                                                                                                                 
        psql                                                                                                                                                  
        pipe                                                                                                                                                  
        moinmoin                                                                                                                                              
        orgtbl                                                                                                                                                
        textile                                                                                                                                               
        mediawiki                                                                                                                                             
        html                                                                                                                                                  
        grid                                                                                                                                                  
        double                                                                                                                                                
        tsv                                                                                                                                                   
        ascii
        csv
        fancy_grid
        rstFor example:Oracle-11g hr@xe:HR> format  fancy_grid
Changed table format to fancy_grid
Time: 0.000s
Oracle-11g hr@xe:HR> select * from hr.DEPARTMENTS where MANAGER_ID >200
╒═════════════════╤═══════════════════╤══════════════╤═══════════════╕
│   DEPARTMENT_ID │ DEPARTMENT_NAME   │   MANAGER_ID │   LOCATION_ID │
╞═════════════════╪═══════════════════╪══════════════╪═══════════════╡
│              20 │ Marketing         │          201 │          1800 │
├─────────────────┼───────────────────┼──────────────┼───────────────┤
│              40 │ Human Resources   │          203 │          2400 │
├─────────────────┼───────────────────┼──────────────┼───────────────┤
│              70 │ Public Relations  │          204 │          2700 │
├─────────────────┼───────────────────┼──────────────┼───────────────┤
│             110 │ Accounting        │          205 │          1700 │
╘═════════════════╧═══════════════════╧══════════════╧═══════════════╛
4 row s in set
Time: 0.003s
Oracle-11g hr@xe:HR> format csv
Changed table format to csv
Time: 0.000s
Oracle-11g hr@xe:HR> select * from hr.DEPARTMENTS where MANAGER_ID >200
DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID
20,Marketing,201,1800
40,Human Resources,203,2400
70,Public Relations,204,2700
110,Accounting,205,1700

4 row s in set
Time: 0.002slistThelistcommand shows all the schemas available.For exampleOracle-11g hr@xe:HR> list
+-------------+
| OWNER       |
+-------------+
| MDSYS       |
| CTXSYS      |
| HR          |
| SYSTEM      |
| APEX_040000 |
| XDB         |
| SYS         |
+-------------+showTheshowcommand shows all the tables in a schema.For exampleOracle-11g hr@xe:HR> show HR
+------------------+
| TABLE_NAME       |
+------------------+
| LOCATIONS        |
| EMPLOYEES        |
| EMP_DETAILS_VIEW |
| REGIONS          |
| JOBS             |
| COUNTRIES        |
| JOB_HISTORY      |
| DEPARTMENTS      |
+------------------+spoolThespoolcommand will append the output of subsequent statements to a file.nospoolwill stop appending the output to the file.oncespools the output for only the next command.For example:Oracle-11g hr@xe:HR> spool output.txt
Time: 0.001s
Oracle-11g hr@xe:HR> select * from hr.DEPARTMENTS where MANAGER_ID > 200
+---------------+------------------+------------+-------------+
| DEPARTMENT_ID | DEPARTMENT_NAME  | MANAGER_ID | LOCATION_ID |
+---------------+------------------+------------+-------------+
| 20            | Marketing        | 201        | 1800        |
| 40            | Human Resources  | 203        | 2400        |
| 70            | Public Relations | 204        | 2700        |
| 110           | Accounting       | 205        | 1700        |
+---------------+------------------+------------+-------------+
4 row s in set
Time: 0.003s
Oracle-11g hr@xe:HR> exit
root@b809269946dd:/# cat output.txt 
Oracle-11g hr@xe:HR> select * from hr.DEPARTMENTS where MANAGER_ID > 200
+---------------+------------------+------------+-------------+
| DEPARTMENT_ID | DEPARTMENT_NAME  | MANAGER_ID | LOCATION_ID |
+---------------+------------------+------------+-------------+
| 20            | Marketing        | 201        | 1800        |
| 40            | Human Resources  | 203        | 2400        |
| 70            | Public Relations | 204        | 2700        |
| 110           | Accounting       | 205        | 1700        |
+---------------+------------------+------------+-------------+exitExit the CLI app withexit,quitor\q.faqDPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". Seehttps://oracle.github.io/odpi/doc/installation.html#linuxfor helpIf you see this error message make sure that the$ORACLE_HOME/libis on$LD_LIBRARY_PATH. This is needed by cx-oracle to make the database connection. As a sanity checkls $ORACLE_HOME/libshould list the oracle libraries.Update the library-path with:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/libwindows supportIn principleokclishould work on Windows but it has only been tested on Linux. If you're interested in testing on Windows please raise an issue.thanksThanks tomycli. Most of the features (e.g. syntax highlighting, auto-complete) were implemented by the mycli core team for MySQL.