Plotting Graphs with Python and Oracle Database

--

In response to a question, I put together a simple Python example that draws a bar graph from an Oracle Database query. The key requirement in this example is to get the data as a list of values, which I did with list comprehension (see line 33). I used the latest Python Oracle Database driver, recently renamed to python-oracledb. You can install it with a command likepython -m pip install oracledb --upgrade Similar code works fine with the older version of the driver (i.e. cx_Oracle) — change the import call to import cx_Oracle as oracledb and add a call toinit_oracle_client() if needed.

The code is:

The output is like:

A bar graph drawn by pyplot from an Oracle Database query

--

--

Christopher Jones
Christopher Jones

Written by Christopher Jones

Oracle Database Product Manager for language drivers including Python python-oracledb, Node.js node-oracledb, PHP OCI8 and more! On Mastodon: @cjbj@phpc.social

No responses yet