{"id":27531233,"url":"https://github.com/richardschoen/pythonibmicli","last_synced_at":"2025-12-30T22:06:46.747Z","repository":{"id":212980346,"uuid":"611510342","full_name":"richardschoen/pythonibmicli","owner":"richardschoen","description":"IBM i Python cli Scripts with CL commands to query databases or insert, update delete individual records. These can be used on any platform including IBMi - AS/400 with QSHONI/QSHEXEC","archived":false,"fork":false,"pushed_at":"2023-12-17T17:51:32.000Z","size":36,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-24T07:55:55.244Z","etag":null,"topics":["as400","cl","cli","clp","cmd","command","command-line","db2","ibm-db","ibm-db-dbi","ibmi","mariadb","pase","postgresql","python","qsh","qshell","sql","sql-server","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardschoen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-09T01:03:32.000Z","updated_at":"2025-05-22T03:38:01.000Z","dependencies_parsed_at":"2023-12-17T18:46:23.455Z","dependency_job_id":null,"html_url":"https://github.com/richardschoen/pythonibmicli","commit_stats":null,"previous_names":["richardschoen/pythonibmicli"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/richardschoen/pythonibmicli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Fpythonibmicli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Fpythonibmicli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Fpythonibmicli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Fpythonibmicli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardschoen","download_url":"https://codeload.github.com/richardschoen/pythonibmicli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Fpythonibmicli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28132977,"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-12-30T02:00:05.476Z","response_time":64,"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":["as400","cl","cli","clp","cmd","command","command-line","db2","ibm-db","ibm-db-dbi","ibmi","mariadb","pase","postgresql","python","qsh","qshell","sql","sql-server","sqlite"],"created_at":"2025-04-18T17:49:29.736Z","updated_at":"2025-12-30T22:06:46.716Z","avatar_url":"https://github.com/richardschoen.png","language":"Python","readme":"# IBM i Python CLI Scripts to query databases or insert, update delete individual records\nThis repository will contain ready-to-run command line (CLI) utility app examples for querying, inserting and updating data using a command line Python script.   \n\nSample CL wrappers will also be added that call the scripts via an IBM i CL command.     \n\n```Several versions will be added for: IBM i DB2, ODBC, SQLite, MariaDB, PostgreSQL and SQL Server. Possibly more.```\n\n# Use Case\nRPG and CL cannot easily directly communicate with remote databases.   \n\nThese Python scripts and commands will provide an easy way to query remote data and bring back results as ```CSV or other delimited resultsets``` for consumption directly from the IFS by an RPG program or by importing to a database via the ```CPYFRMIMP``` command (Copy From Import File).   \n\nRecord results can also be returned in ```JSON``` format. These results can be then consumed in RPG via the ```YAJL``` library ported by Scott Klement (https://www.scottklement.com/yajl), ```noxDB``` library (https://github.com/sitemule/noxDB) or the ```DATA-INTO``` opcode in RPG (https://www.ibm.com/docs/en/i/7.5?topic=codes-data-into-parse-document-into-variable).   \n\nINSERT, UPDATE and DELETE commands can also be issued to update the selected remote database as well covering the entire CRUD cycle for data access. \n\n# ibmdbcli.py - Python command line interface (CLI) script to query or write data to DB2 with ibm_db driver\nThis script will run IBM DB2 database operations via native DB2 driver: python-ibmdb.\n\nThis script is similar to the IBM i ```db2util``` pase app for querying data, but it's a native Python scripting.\n\n**IBM i prerequisites**   \nIBM i V7R3 and above   \nPython 3.6 or 3.9 on IBM i   \nQShell on i - (http://www.github.com/richardschoen/qshoni)  \n\n**Pip packages needed**  \n```pip install ibm_db``` (IBM Database driver)  \n  \n**Parameters**\n```\n--action - Action to perform. \n           QUERY - SQL SELECT Query     \n           NONQUERY - SQL non query action. Ex: INSERT, UPDATE, DELETE  \n           **NOTE: The CLI will not currently work with stored procedures.  \n--sql - SQL query or action to run  \n--outputtype - Output format for query. csv or json formats  \n--delimiter - Output file delimiter for query to csv. Default = ,  \n--outputfile - Output text file for QUERY action. No output for NONQUERY.  \n--replace - Replace output file for query. True/False. Default = True  \n```\n\n**Examples**\n\nQuery table QIWS/QCUSCTDT and write to IFS file as CSV\n```python3 ibmdbcli.py --sql \"select * from qiws.qcustcdt\" --outputfile \"/tmp/qcustcdt.csv\" --replace \"true\" --outputtype \"csv\" --delimiter \",\"```  \n\nQuery table QIWS/QCUSCTDT and write to IFS file as JSON\n```python3 ibmdbcli.py --sql \"select * from qiws.qcustcdt\" --outputfile \"/tmp/qcustcdt.csv\" --replace \"true\" --outputtype \"json\"```  \n\nInsert new record into table QIWS/QCUSTCDT\n```python3 ibmdbdb.py --sql \"insert into qiws.qcustcdt (cusnum,lstnam) values(123456,'Jones') \" --outputfile \"/tmp/qcustcdt.txt\" --action \"nonquery\"```\n\n# IBMDBCLI - CL wrapper command front end for ibmdbcli.py\n\nQuery table QIWS/QCUSCTDT and write to IFS file as CSV file.   \nCalls the ibmdbcli.py Python script via the QSHONI/QSHEXEC command. \n\n```\nIBMDBCLI SCRIPTFILE('/pythonapps/ibmdbcli.py')                                      \n         SQL('select * from qiws.qcustcdt')                  \n         ACTION('QUERY')                                     \n         OUTPUTFILE('/tmp/qcustcdt.csv')                          \n         FIELEDELIM(',')                                     \n         REPLACE(*YES) \n         OUTPUTTYPE(CSV)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardschoen%2Fpythonibmicli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardschoen%2Fpythonibmicli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardschoen%2Fpythonibmicli/lists"}