Haig Simci
Haig Simci

Reputation: 51

How can I insert rows into Oracle SQL databse from a raspberry pi using python?

I'm currently working on a personal project which involves:

Here's what I'm trying to-do: I need the Raspberry Pi to send the UID (unique identification number) which I've read from the RFID tag and insert a row into my SQL database with the UID. The information read from the RFID tag is a bunch of numbers which can be stored as a String.

I am currently able to read tags and print the UID onto the screen. The reading is being processed by a Python script which I've modified from a source code I found online.

I am struggling to send the UID to my SQL database. I have looked into cx_Oracle but it seems that it doesn't exist for the ARM Architecture which the Raspberry Pi uses. I have also looked into pyodbc but I can't seem to get that working either. Here is my Python script which I am using to read the RFID tags.

Extra Info : I am a noob when it comes to Python, I have a background in C, Java, JDBC and Oracle SQL. I understand how JDBC connections work but I can't seem to implement the same theory in Python. To anyone that is a pro at Python, please feel free to modify my code below to access an Oracle SQL database. The credentials to my database is as follows:

Upvotes: 2

Views: 1678

Answers (1)

jason.kaisersmith
jason.kaisersmith

Reputation: 9610

To access an oracle database then you need client libraries on the Rpi.

As you seem to have discovered already, these don't exist for the ARM Linux architecture, and certainly not for the Raspian O/S.

You could look into using an ODBC driver for RPi to see if you can get this to work.

This Post shows what somebody has tried this already.

And I also found this article, where somebody claims to have gotten this working for Rpi via PHP. The company who's driver he used (which he works for) also have a python driver. However, looking on their website the software is commercial (free trial available) and does not claim to support ARM Linux. Although you could try with their free trial.

Here is a list of other ODBC drivers which have python drivers available.

Although I have never tried it or have experience in this area, there is a way to expose SOAP web services from the oracle database. So you could try his approach instead, so the DB exposes the services and then you access the web service from python. But as I have not done it I don't know about any limitation or if this would actually work for you.

Otherwise, you would need to take a different approach and use some kind of middle ware between the Rpi and the DB to receive the data and insert it. Or use another database!

Upvotes: 1

Related Questions