As the department's Oracle database is a protected host, we must first tunnel into the department before accessing the database. The tunnel must remain open throughout the duration you want to connect to the database.
Depending on whether you are working from Syzygy or your own local computer, step 1 will vary. Step 2 will remain the same.
CWL with your actual CWL id.ssh -l CWL -L 127.0.0.1:1522:dbhost.students.cs.ubc.ca:1522 remote.students.cs.ubc.caThe authenticity of host 'remote.students.cs.ubc.ca (<some IP address>)' can't be established.
ED25519 key fingerprint is <some series of numbers and letters>.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
exit into the terminal window and hit enter to close the session.This section is for anyone who has installed a version on Jupyter on their computer and wants to use this local installation to access the UBC CS department's Oracle database. It assumes that you have already installed Jupyter, cx_Oracle, and the Oracle Instant Client. If you have not done these things, please refer to the "Programming Environment" page on Canvas for instructions on how to do so.

ssh -l username -L localhost:1522:dbhost.students.cs.ubc.ca:1522 remote.students.cs.ubc.ca
Be sure to replace username with your actual CWL username.
Assuming you have not removed the tables created by the bookbiz.sql file from an earlier assignment, you should be able to test your connection by making a query on one of the bookbiz tables.
First, use conda or pip to install the "oracledb" package (documentation). You should also follow the environment setup steps under the Programing Environment page on Canvas.
Try running the following in a Jupyter cell. Be sure to replace username with ora_CWLID (no @stu required) and password with "a" followed by your student number (e.g., a12345678).
dsn = oracledb.makedsn("localhost", 1522, service_name="stu")
connection = oracledb.connect(user="username", password="pwd", dsn=dsn, encoding="UTF-8")
cur = connection.cursor()
for row in cur.execute("select * from titles"):
print(row)
cur.close()
Update: since cx_Oracle no longer works properly on new machines, we recommend you use oracledb in place of cx_Oracle.
Note: If you get an error cx_Oracle error. DPI-1047: Cannot locate a 64-bit Oracle Client library, please check out this post. Warning: If you are following the first answer and you are using Jupyter Notebook, make sure you are copying those dll files to the directory where you installed Anaconda (e.g., inside the directory named "Anaconda3 (64-bit)"). This is because sometimes you have different Python in your computer, and you want to make changes to the one that you are currectly using in the Jupyter Notebook.
If you are using a Mac, you can move the entire instant_client folder and make sure to set the lib_dir to that location. For example, if your instant_client is in your Downloads folder, the code added should be cx_Oracle.init_oracle_client(lib_dir= r"Downloads")