0

By using python I am downloading the data into a MySQL database, but I want to change it Oracle.

Can anyone help with this> For the Oracle database I have username, password, hostname, port, and SID. Are these details are enough to change the database?

<` db = MySQLdb.connect("127.0.0.1", "root", "1234")
                cursor = db.cursor()
                try:
                    cursor.execute('create database nasa')
                except:
                    None
                cursor.execute('use nasa')

                cursor.execute(
                    "CREATE TABLE IF NOT EXISTS temperatureTable(date VARCHAR(30) NOT NULL, time VARCHAR(30) NOT NULL, longitude VARCHAR(30) NOT NULL, latitude VARCHAR(30) NOT NULL, temperature VARCHAR(30) NOT NULL, PRIMARY KEY (date, longitude, latitude))")
                lineToBeStored = 0
                for lat in numpy.nditer(latitude):
                    for lon in numpy.nditer(longitude):
                        cursor.execute(
                            "INSERT INTO temperatureTable VALUES('%s', '%s', '%s', '%s', '%s')" % (
                                today, dateTime, lat, lon, temperatureData[lineToBeStored]))`>
4
  • Please try to repair your code, it is hard to read. Use python.org/dev/peps/pep-0008 to see more about that. Also - have you tried to run it on the Oracle database? Commented Nov 21, 2016 at 15:32
  • Did you try it? What happened? Commented Nov 21, 2016 at 15:38
  • Just some advice: database in MySQL is something different as "database" in Oracle. Please read more here: stackoverflow.com/questions/10461861/… . To make a working PK constraint: CONSTRAINT constraint_name PRIMARY KEY (date, longitude, latitude). VARCHAR should work as intended... Also IF NOT EXISTS is not possible in oracle to my knowledge. There are different approaches there. Commented Nov 21, 2016 at 15:47
  • hi , i dono how to add the code into the stack overflow ......but its start from <' db........ Commented Nov 21, 2016 at 16:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.