{"id":29901914,"url":"https://github.com/man-group/okcli","last_synced_at":"2025-08-01T15:15:38.633Z","repository":{"id":57448517,"uuid":"108440319","full_name":"man-group/okcli","owner":"man-group","description":"An Oracle-DB command line client","archived":false,"fork":false,"pushed_at":"2020-09-23T19:21:27.000Z","size":2404,"stargazers_count":53,"open_issues_count":5,"forks_count":9,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-07-31T21:14:26.863Z","etag":null,"topics":["cli","command-line-tool","oracle","oracle-database","sql-client"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/man-group.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-26T16:58:03.000Z","updated_at":"2025-06-14T00:35:48.000Z","dependencies_parsed_at":"2022-09-18T12:30:56.807Z","dependency_job_id":null,"html_url":"https://github.com/man-group/okcli","commit_stats":null,"previous_names":["manahl/okcli"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/man-group/okcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/man-group%2Fokcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/man-group%2Fokcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/man-group%2Fokcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/man-group%2Fokcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/man-group","download_url":"https://codeload.github.com/man-group/okcli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/man-group%2Fokcli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268248983,"owners_count":24219560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line-tool","oracle","oracle-database","sql-client"],"created_at":"2025-08-01T15:15:32.688Z","updated_at":"2025-08-01T15:15:35.675Z","avatar_url":"https://github.com/man-group.png","language":"Python","readme":"# okcli\n[![Build status](https://circleci.com/gh/manahl/okcli.svg?style=svg)](https://circleci.com/gh/manahl/okcli)\n[![PyPi python version](https://img.shields.io/pypi/pyversions/okcli.svg)](https://pypi.org/project/okcli/)\n[![PyPi project version](https://img.shields.io/pypi/v/okcli.svg)](https://pypi.org/project/okcli/)\n\n\nMan Okcli for Oracle Database.\n\nAn Oracle-DB command line client with auto-completion and syntax highlighting that emulates the functionality of [sqlplus](http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html).\n\n### index\n* [install](#install)\n* [user guide](#user-guide)\n* [usage](#usage)\n* [faq](#faq)\n* [ipython](#ipython)\n\n\n# install\nInstall ``okcli`` from [pypi](https://pypi.org/) with [pip](https://pypi.org/project/pip/).\n\n```\n\u003e sudo pip install okcli\n```\n\nor without sudo credentials\n\n```\n\u003e pip install --user okcli\n```\n\n# documentation\nFor documentation and config options see the [user guide](#user-guide) or type ``help`` from within the app.\n\n# demo \n![demo](docs/example.gif)\n\n\n# usage\n```\nUsage: okcli [OPTIONS] [SQLPLUS]\n\n  An Oracle-DB terminal client with auto-completion and syntax highlighting.\n\n  Examples:\n    - okcli -u my_user -h my_host.com -D schema\n    - okcli user/password@tns_name \n    - okcli user/password@tns_name -D schema \n    - okcli user/password@tns_name -e \"query\"\n    - okcli user@tns_name -@ query_file.sql\n\nOptions:\n  -h, --host TEXT         Host address of the database.\n  -P, --port INTEGER      Port number to use for connection.\n  -u, --user TEXT         User name to connect to the database.\n  -p, --password TEXT     Password to connect to the database.\n  -v, --version           Output okcli's version.\n  -D, --database TEXT     Database to use.\n  -R, --prompt TEXT       Prompt format (Default: \"\\t \\u@\\h:\\d\u003e \").\n  -l, --logfile FILENAME  Log every query and its results to a file.\n  --okclirc PATH         Location of okclirc file.\n  --auto-vertical-output  Automatically switch to vertical output mode if the\n                          result is wider than the terminal width.\n  -t, --table             Display batch output in table format.\n  --csv                   Display batch output in CSV format.\n  --warn / --no-warn      Warn before running a destructive query.\n  --login-path TEXT       Read this path from the login file.\n  -e, --execute TEXT      Execute command and quit.\n  -@, --filename TEXT     Execute commands in a file.\n  --help                  Show this message and exit.\n```\n\n\n\n\n# user-guide\n* [display help text](#help)\n* [app config](#config)\n* [set colour scheme](#colours)\n* [execute host shell commands](#shell)\n* [execute commands from file](#exec-file)\n* [describe](#describe)\n* [stored procedures](#stored-procs)\n* [favourite commands](#favourite-commands)\n* [escape to an editor to finish writing an SQL statement](#edit)\n* [change output format](#format)\n* [list all schemas in database](#list)\n* [list all tables in  a schema](#show)\n* [spool (append) query output to a file](#spool)\n* [ipython](#ipython)\n* [exit the app](#exit)\n\n\n# help\nThe ``help`` command displays help text for all other commands.\n\n# config\nThe file ``~/.okclirc`` is created upon installation with config for okcli.\n\nThings like colour-scheme, prompt-format, log-file location etc. can be updated there.\n\n# colours\n\nThe ``syntax_style`` parameter in the [config-file](#config) sets the syntax colour scheme, select from the following:\n\n```\n# Syntax coloring style. Possible values (many support the \"-dark\" suffix):\n# manni, igor, xcode, vim, autumn, vs, rrt, native, perldoc, borland, tango, emacs,\n# friendly, monokai, paraiso, colorful, murphy, bw, pastie, paraiso, trac, default,\n# fruity.\n```\n\nOther style options (eg. the status bar) can also be set in the [config-file](#config).\n\n# shell\nStart a statement with ``! `` to execute it as a shell command.\n\nFor example\n```\nOracle-18c oracle@system:hr\u003e ! echo Hello Okcli\nHello Okcli\n```\n\n# exec-file\nExecute sql statements from a file by passing it as an argument with ``-@``.\n\nFor example:\n```\n \u003e cat date_query.sql \nselect sysdate from dual\n \u003e okcli hr@xe:HR -@date_query.sql\nSYSDATE\n2019-03-12 16:42:34\n```\n\n# describe \nThe ``describe`` command will show for a given table or view:\n* each column name, its datatype, if it's nullable\n* primary-key constraints (if it's a table)\n* foreign-key constraints (if it's a table)\n* the SQL query used to create the view (if it's a view)\n\nFor example:\n```\nOracle-11g hr@xe:HR\u003e desc HR.EMPLOYEES\n+----------------+-----------+-------------+----------+\n| COLUMN_NAME    | DATA_TYPE | DATA_LENGTH | NULLABLE |\n+----------------+-----------+-------------+----------+\n| EMPLOYEE_ID    | NUMBER    | 22          | N        |\n| FIRST_NAME     | VARCHAR2  | 20          | Y        |\n| LAST_NAME      | VARCHAR2  | 25          | N        |\n| EMAIL          | VARCHAR2  | 25          | N        |\n| PHONE_NUMBER   | VARCHAR2  | 20          | Y        |\n| HIRE_DATE      | DATE      | 7           | N        |\n| JOB_ID         | VARCHAR2  | 10          | N        |\n| SALARY         | NUMBER    | 22          | Y        |\n| COMMISSION_PCT | NUMBER    | 22          | Y        |\n| MANAGER_ID     | NUMBER    | 22          | Y        |\n| DEPARTMENT_ID  | NUMBER    | 22          | Y        |\n+----------------+-----------+-------------+----------+\nTime: 0.098s\n\n+---------------------+\n| PRIMARY_KEY_COLUMNS |\n+---------------------+\n| EMPLOYEE_ID         |\n+---------------------+\nTime: 0.370s\n\n+---------------+---------------------------+\n| COLUMN_NAME   | FOREIGN_KEY_CONSTRAINT    |\n+---------------+---------------------------+\n| DEPARTMENT_ID | DEPARTMENTS.DEPARTMENT_ID |\n| JOB_ID        | JOBS.JOB_ID               |\n| MANAGER_ID    | EMPLOYEES.EMPLOYEE_ID     |\n+---------------+---------------------------+\nTime: 2.228s\n```\n# stored-procedures\nStored-procedures can be run with the ``exec`` command. \n\nFor example\n```\nOracle-11g hr@xe:HR\u003e exec some_schema.my_procedure(arg1, 'arg2')\n```\n\n# favourite-commands\nThe ``\\fs [name]`` command will save the current statement with a name.\n\nThe ``\\f [name]`` command will load the statement with that name or list all the saved statements if no  name is given.\n\nThe ``\\fd [name]`` command will delete the saved statement.\n\nFor example\n```\nOracle-11g hr@xe:HR\u003e \\fs depts select  * from HR.DEPARTMENTS where MANAGER_ID \u003e 200                                                                           \nSaved.                                                                                                                                                        \nTime: 0.003s                                                                                                                                                  \nOracle-11g hr@xe:HR\u003e \\f depts                                                                                                                                 \n\u003e select  * from HR.DEPARTMENTS where MANAGER_ID \u003e 200                                                                                                        \n+---------------+------------------+------------+-------------+\n| DEPARTMENT_ID | DEPARTMENT_NAME  | MANAGER_ID | LOCATION_ID |\n+---------------+------------------+------------+-------------+\n| 20            | Marketing        | 201        | 1800        |\n| 40            | Human Resources  | 203        | 2400        |\n| 70            | Public Relations | 204        | 2700        |\n| 110           | Accounting       | 205        | 1700        |\n+---------------+------------------+------------+-------------+\n4 row s in set\nTime: 0.002s\nOracle-11g hr@xe:HR\u003e \\f\n+-------+------------------------------------------------------+\n| Name  | Query                                                |\n+-------+------------------------------------------------------+\n| depts | select  * from HR.DEPARTMENTS where MANAGER_ID \u003e 200 |\n+-------+------------------------------------------------------+\nTime: 0.001s\n\nNo favorite query:\nTime: 0.000s\nOracle-11g hr@xe:HR\u003e \\fs depts_2 select  * from HR.DEPARTMENTS where MANAGER_ID \u003c 200\nSaved.\nTime: 0.001s\nOracle-11g hr@xe:HR\u003e \\f\n+---------+------------------------------------------------------+\n| Name    | Query                                                |\n+---------+------------------------------------------------------+\n| depts   | select  * from HR.DEPARTMENTS where MANAGER_ID \u003e 200 |\n| depts_2 | select  * from HR.DEPARTMENTS where MANAGER_ID \u003c 200 |\n+---------+------------------------------------------------------+\nTime: 0.001s\n\n\n```\n\n# edit\nWhen writing a statement you can escape to your favourite editor (set by ``$EDITOR``) by adding  ``ed`` to the start of the query. \n\nWhen you save and exit the file it will take you back to the CLI with the statement that you finished  editing in the file.\n\nFor example:\n```\nOracle-11g hr@xe:HR\u003e ed select * from\n```\n\n# format\nThe ``format`` command sets the format of the query-output (if there is any).\n\nThe supported output formats are:\n```\n        jira                                                                                                                                                  \n        latex                                                                                                                                                 \n        github                                                                                                                                                \n        latex_booktabs                                                                                                                                        \n        vertical                                                                                                                                              \n        simple                                                                                                                                                \n        plain                                                                                                                                                 \n        psql                                                                                                                                                  \n        pipe                                                                                                                                                  \n        moinmoin                                                                                                                                              \n        orgtbl                                                                                                                                                \n        textile                                                                                                                                               \n        mediawiki                                                                                                                                             \n        html                                                                                                                                                  \n        grid                                                                                                                                                  \n        double                                                                                                                                                \n        tsv                                                                                                                                                   \n        ascii\n        csv\n        fancy_grid\n        rst\n```\n\nFor example:\n```\nOracle-11g hr@xe:HR\u003e format  fancy_grid\nChanged table format to fancy_grid\nTime: 0.000s\nOracle-11g hr@xe:HR\u003e select * from hr.DEPARTMENTS where MANAGER_ID \u003e200\n╒═════════════════╤═══════════════════╤══════════════╤═══════════════╕\n│   DEPARTMENT_ID │ DEPARTMENT_NAME   │   MANAGER_ID │   LOCATION_ID │\n╞═════════════════╪═══════════════════╪══════════════╪═══════════════╡\n│              20 │ Marketing         │          201 │          1800 │\n├─────────────────┼───────────────────┼──────────────┼───────────────┤\n│              40 │ Human Resources   │          203 │          2400 │\n├─────────────────┼───────────────────┼──────────────┼───────────────┤\n│              70 │ Public Relations  │          204 │          2700 │\n├─────────────────┼───────────────────┼──────────────┼───────────────┤\n│             110 │ Accounting        │          205 │          1700 │\n╘═════════════════╧═══════════════════╧══════════════╧═══════════════╛\n4 row s in set\nTime: 0.003s\nOracle-11g hr@xe:HR\u003e format csv\nChanged table format to csv\nTime: 0.000s\nOracle-11g hr@xe:HR\u003e select * from hr.DEPARTMENTS where MANAGER_ID \u003e200\nDEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID\n20,Marketing,201,1800\n40,Human Resources,203,2400\n70,Public Relations,204,2700\n110,Accounting,205,1700\n\n4 row s in set\nTime: 0.002s\n```\n\n# list\nThe ``list`` command shows all the schemas available.\n\nFor example\n```\nOracle-11g hr@xe:HR\u003e list\n+-------------+\n| OWNER       |\n+-------------+\n| MDSYS       |\n| CTXSYS      |\n| HR          |\n| SYSTEM      |\n| APEX_040000 |\n| XDB         |\n| SYS         |\n+-------------+\n```\n\n# show\nThe ``show`` command shows all the tables in a schema.\n\nFor example\n```\nOracle-11g hr@xe:HR\u003e show HR\n+------------------+\n| TABLE_NAME       |\n+------------------+\n| LOCATIONS        |\n| EMPLOYEES        |\n| EMP_DETAILS_VIEW |\n| REGIONS          |\n| JOBS             |\n| COUNTRIES        |\n| JOB_HISTORY      |\n| DEPARTMENTS      |\n+------------------+\n```\n# spool\nThe ``spool`` command will append the output of subsequent statements to a file. \n\n``nospool`` will stop appending the output to the file.\n\n``once`` spools the output for only the next command.\n\nFor example:\n```\nOracle-11g hr@xe:HR\u003e spool output.txt\nTime: 0.001s\nOracle-11g hr@xe:HR\u003e select * from hr.DEPARTMENTS where MANAGER_ID \u003e 200\n+---------------+------------------+------------+-------------+\n| DEPARTMENT_ID | DEPARTMENT_NAME  | MANAGER_ID | LOCATION_ID |\n+---------------+------------------+------------+-------------+\n| 20            | Marketing        | 201        | 1800        |\n| 40            | Human Resources  | 203        | 2400        |\n| 70            | Public Relations | 204        | 2700        |\n| 110           | Accounting       | 205        | 1700        |\n+---------------+------------------+------------+-------------+\n4 row s in set\nTime: 0.003s\nOracle-11g hr@xe:HR\u003e exit\nroot@b809269946dd:/# cat output.txt \nOracle-11g hr@xe:HR\u003e select * from hr.DEPARTMENTS where MANAGER_ID \u003e 200\n+---------------+------------------+------------+-------------+\n| DEPARTMENT_ID | DEPARTMENT_NAME  | MANAGER_ID | LOCATION_ID |\n+---------------+------------------+------------+-------------+\n| 20            | Marketing        | 201        | 1800        |\n| 40            | Human Resources  | 203        | 2400        |\n| 70            | Public Relations | 204        | 2700        |\n| 110           | Accounting       | 205        | 1700        |\n+---------------+------------------+------------+-------------+\n```\n\n# ipython\n\n`okcli` has support for `ipython` (and hence Jupiterhub notebooks), giving full support for eg. auto-complete on queries from within `ipython`.\n\nTo drop into an `okcli` shell from an ipython session, load the `okcli.magic` module. On exiting the `okcli` shell you drop back into the `ipython` shell with the last query results, as shown below.\n\nThe database connection is cached so subsequent `okcli` calls from the `ipython` session will drop back into the `okcli` shell already logged in.\n\n```\nroot@6df4c32479df:/# ipython\nPython 2.7.15rc1 (default, Nov 12 2018, 14:31:15)\nType \"copyright\", \"credits\" or \"license\" for more information.\n\nIPython 5.8.0 -- An enhanced Interactive Python.\n?         -\u003e Introduction and overview of IPython's features.\n%quickref -\u003e Quick reference.\nhelp      -\u003e Python's own help system.\nobject?   -\u003e Details about 'object', use 'object??' for extra details.\n\nIn [1]: %load_ext okcli.magic\n\nIn [2]: okcli system/oracle@xe\nConnected to: xe\nOracle-11g system@xe:SYSTEM\u003e select  * from hr.COUNTRIES where REGION_ID=1\n+------------+----------------+-----------+\n| COUNTRY_ID | COUNTRY_NAME   | REGION_ID |\n+------------+----------------+-----------+\n| BE         | Belgium        | 1         |\n| CH         | Switzerland    | 1         |\n| DE         | Germany        | 1         |\n| DK         | Denmark        | 1         |\n| FR         | France         | 1         |\n| IT         | Italy          | 1         |\n| NL         | Netherlands    | 1         |\n| UK         | United Kingdom | 1         |\n+------------+----------------+-----------+\n8 row s in set\nTime: 0.002s\nOracle-11g system@xe:SYSTEM\u003e exit\n0 rows affected.\nOut[2]:\n[(u'BE', u'Belgium', 1),\n (u'CH', u'Switzerland', 1),\n (u'DE', u'Germany', 1),\n (u'DK', u'Denmark', 1),\n (u'FR', u'France', 1),\n (u'IT', u'Italy', 1),\n (u'NL', u'Netherlands', 1),\n (u'UK', u'United Kingdom', 1)]\n\nIn [3]: res = _\n\n```\n\n# exit\nExit the CLI app with ``exit``, ``quit`` or  ``\\q``.\n\n# faq\n\n### DPI-1047: Cannot locate a 64-bit Oracle Client library: \"libclntsh.so: cannot open shared object file: No such file or directory\". See https://oracle.github.io/odpi/doc/installation.html#linux for help\n \nIf you see this error message make sure that the ``$ORACLE_HOME/lib`` is on ``$LD_LIBRARY_PATH``. This is needed by cx-oracle to make the database connection. As a sanity check ``ls $ORACLE_HOME/lib`` should list the oracle libraries.\n\nUpdate the library-path with:\n\n```\nexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib\n```\n\n### windows support\nIn principle ``okcli`` should work on Windows but it has only been tested on Linux. If you're interested in testing on Windows please raise an issue.\n\n# thanks\nThanks to [mycli](https://github.com/dbcli/mycli). Most of the features (e.g. syntax highlighting, auto-complete) were implemented by the mycli core team for MySQL.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fman-group%2Fokcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fman-group%2Fokcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fman-group%2Fokcli/lists"}