Python Developer Track for Oracle JSON and Duality Views - Part 1: Create and configure your Oracle 23c
Javier
Posted on November 22, 2023
On this tutorial we are going to install and configure Oracle 23c Free Developer Release. For that, we are going to use Oracle Cloud Infrastructure were I have a VM just created. You can run all the tutorial at your laptop or a custom VM.
Oracle Database 23c Free includes all the features and capabilities, and as it's name says, it is fully free! If you want to know all the details, you can go to the webpage here: https://www.oracle.com/uk/database/free/.
Let's install it. There are different ways of installing it, on this tutorial we are going to use the rpm provided at the webpage. Let's install it as root user. We have to install the prerequisites package and the Oracle Database 23c free:
sudo su
wget https://yum.oracle.com/repo/OracleLinux/OL8/developer/x86_64/getPackage/oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm
wget https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23c-1.0-1.el8.x86_64.rpm
yum -y localinstall oracle-database*
Now let's configure it. For that, we will have to provide a password for the SYS, SYSTEM and ADMIN user. We are going to use this password for the whole workshop: PassworD123##
Once the rpm has been installed, you have to configure it with the following command:
/etc/init.d/oracle-free-23c configure
You will have to introduce your password or the one used as example in this tutorial. Wait until the configuration reaches 100%.
Once configured, let's set the environment variables for sqlplus. We will define them at .bashrc so it will be configured every time you log in again. We will define them for root user:
cd /root
echo 'export ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree' >> .bashrc
echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> .bashrc
. .bashrc
Also we are going to configure the Oracle 23c Free to automatically start with the VM, and also we are going to open the firewall port in case you want to connect from outside:
systemctl enable oracle-free-23c
firewall-cmd --permanent --add-port=1521/tcp
firewall-cmd --reload
We are ready to go! Before starting, let's create a new user. We will use this user for the whole workshop:
sqlplus sys/PassworD123##@localhost:1521/FREEPDB1 as sysdba
create user myapp identified by PassworD123##;
grant db_developer_role to myapp;
alter user myapp quota unlimited on users;
exit;
Granting the db_developer_role, we will have all the privileges required.
As last step, we are going to configure Python. In order to use Python and Oracle 23c I need a version 3.7 or higher. Let's check it:
python --version
In this case I have version 3.6. I'm going to proceed to install Python 3.11 and pip.
yum install python3.11
yum install python3.11-pip
Now let's select Python 3.11 as default version for Python:
update-alternatives --config python3
There are 2 programs which provide 'python3'.
Selection Command
-----------------------------------------------
*+ 1 /usr/bin/python3.6
2 /usr/bin/python3.11
Enter to keep the current selection[+], or type selection number: 2
Finally, install the Python driver for Oracle, which is called oracledb:
python -m pip install oracledb --upgrade
We are done! We have Oracle 23c Free up and running and our Python environment set. On the next tutorial, I will be explaining the first steps on Python and Oracle 23c: https://dev.to/javierdelatorre/python-developer-track-for-oracle-json-and-duality-views-part-2-first-steps-with-oracle-and-python-2c0m
Posted on November 22, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
December 21, 2023