Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Accesing Oracle DB with python using the Oracle VM #
- # ================================================== #
- # STEP 1: Installing pip over the proxy
- # --------------------------------------
- sudo yum install install python-pip
- # NOTE: It might be necessary to configure first the http proxy
- # In order to figure out the proxy used by the Oracle VM host
- # we can use the following command in Windows 10: netsh winhttp show proxy
- # REF: https://superuser.com/questions/346372/how-do-i-know-what-proxy-server-im-using
- # C:\Users\Alfa>netsh winhttp show proxy
- # Aktuelle WinHTTP-Proxyeinstellungen:
- # Proxyserver : alfaproxy:3128
- # STEP 2: Exporting the proxy to the user environment
- # ----------------------------------------------------
- # In case the Oracle VM is not able to connect to the internet in order to download
- # packages, we have to export the proxy settings to the environment.
- [oracle@localhost oracle]$ export https_proxy=alfaproxy:3128
- # STEP 3: Installing python3 and PIP
- # -----------------------------------
- # Oracle VM does not come preloaded with python3-pip so I had to install that one
- # REF: https://superuser.com/questions/1137207/cannot-install-python-pip-with-yum
- [oracle@localhost oracle]$ sudo yum install python3 python3-pip
- # STEP 4: Install cx_Oracle from within Python using PIP
- # -------------------------------------------------------
- # The final required step is to install cx_Oracle using PIP
- # REF: https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
- [oracle@localhost oracle]$ sudo python3 -m pip install cx_Oracle
- Installing collected packages: cx-Oracle
- Successfully installed cx-Oracle-7.2.3
- # STEP 5: Testing Oracle CX
- # --------------------------
- # To test the connection to the database within python you can type the following
- [oracle@localhost oracle]$ python3
- Python 3.6.8 (default, Aug 7 2019, 08:02:28)
- [GCC 4.8.5 20150623 (Red Hat 4.8.5-39.0.1)] on linux
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import cx_Oracle
- >>> connection = cx_Oracle.Connection('hr', 'oracle', 'localhost:1521/orcl')
- >>> connection.version
- '19.3.0.0.0'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement