473,383 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

python + ODBC + Oracle + MySQL - money

Hi,

I'm fairly new to Python so please pardon any dumbness on my part.

I plan to write an app in Python that will run on Linux and would need
to connect to Oracle and MySQL. I could use MySQLdb for MySQL and
cx_oracle for Oracle, but 2 different APIs in the same app is kind of
painful.

So I have unixODBC that gives me ODBC on Linux. The best ODBC access
for Python I know is mxODBC. But that is not free for commercial use.
Could someone tell me if there are other choices I have?

Thanks..

Nov 10 '05 #1
4 2842
Well having two different Databases from one app could be painful, but
I think that using Python and a "Divide and Conquer" aproach might be
your best GPL way of handling this. Start up a set of python Classes
that just does the access to the MySQL database. Get these working,
just concentrate on building the Database accesses you will need for
your app, and give the functions sensible, and relatively verbose,
names. Next take step two, doing that same thing (In a different
directory, with a slightly different naming convention for classes
maybe), but for the Oracle Database, and test that out and get that up
and running. Now you have two apps, one for MySQL and one for Oracle.

Now the step that you might not catch on about until you have more
expereience using Python. Because of the very slick and intelligent way
that Python handles naming and operator overloading you just need to
write another set of classes that is you application.
This application can just make use of the other two DB apps you just
created by calling those classes (Hence why I suggested careful naming,
and following some sort of convention for the naming). This will
eventually translate into your app, remember you can do all the fancy
User Interface work and Program Logic work in the third set of classes
(The APP classes). I'm not sure how complicated the app is, but this
sounds like a reasonalbe high level aproach. And if you boss asks
questions about this methodology just tell him/her know that you got
recommend this approach by a Graduate of the University of Toronto with
a degree in Computre Engineering. :-P

So, hope this helps, feel free to ask more questions, hopefully others
will have some more ideas to share.

My two cents,
Andy

Nov 10 '05 #2
In my testing, I need to connect to Oracle, SQL Server and DB2 on
various platforms. I have a base class with all the common code, and
derived classes for each specific database type using specific database
modules such as cxOracle, mxODBC and pyDB2. The derived classes are
pretty thin, containing only some syntax peculiarities for a given
database type. The code is clean and portable.

Grig

Nov 10 '05 #3
Grig Gheorghiu wrote:
In my testing, I need to connect to Oracle, SQL Server and DB2 on
various platforms. I have a base class with all the common code, and
derived classes for each specific database type using specific database
modules such as cxOracle, mxODBC and pyDB2. The derived classes are
pretty thin, containing only some syntax peculiarities for a given
database type. The code is clean and portable.


So maybe you're lucky that all your database modules use the same access
to query parameters. MySQLdb and cx_Oracle would be different in that
MySQLdb has paramstyle = "format" and cx_Oracle has paramstyle =
"qmark/named", i. e. to query a specific record of the person table you
would use

p_id = 4711
cur.execute("select firstname from person where person_id=%s", (p_id,))

using MySQLdb, and:

cur.execute("select firstname from person where person_id=?", (p_id,))

using cx_Oracle.

Now, probably a lot of people have written wrappers for DB-API modules
that translate one paramstyle to the other. The most sensible solution
is to translate the format/pyformat one to others.

Often, one other solution is to use a higher-level database interface
uses your database modules internally, but has the same consistent
interface for the outside.

In my recent evaluations, I liked PyDO2 for this
(http://skunkweb.sourceforge.net/pydo2.html). Unlike SQLObject, it is
able to use MySQL and Oracle now, though there is work underway to add
Oracle support to SQLObject.

OTOH, the advice to use MySQLdb and cx_Oracle directly is probably a
good one, especially for a newcomer to Python. It's a good way to learn
Python and learning the Python DB-API is a good idea if you want to do a
database application in Python. You can use higher-level interfaces (or
write them yourself) later on.

And if this is serious work with business value, then just buying a
mxODBC license and go on with the real problem is probably the most
sensible solution.

You can use the time saved for learning Python, then, which is perhaps
more fun :-)

Cheers,

-- Gerhard

Nov 10 '05 #4
Yes, I did run into the difference in the parameter styles, so I deal
with that in the database-specific classes. It's not a huge difficulty
though.

Grig

Nov 10 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dan Ellis | last post by:
Hi, I've been down so many dead ends trying to get something working, so I'm really hoping someone can help out. I need to access an Oracle database running on a Windows server from Python...
3
by: francisl | last post by:
We have to build some script were I work to make a dynamic server inventory. But, the project team, a windows crew, start it all in vbscript and on mssql. Note, due to political reason, we can...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
3
by: Alex | last post by:
I have developed a VB application that uses Oracle 8i database for backend. The database server is on the local network. From my development machine, the application connects (via ODBC) to the...
133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
10
by: callmebill | last post by:
I'm getting my feet wet with making Python talk to MySQL via ODBC. I started on Windows, and it went smoothly enough due to the ODBC stuff that apparently is native to Python at least on windows...
9
by: Jacques Lebastard | last post by:
I have a problem writing PHP ODBC scripts that suit both MySQL and PostgreSQL. So far, the following syntaxes seem to apply to each database (this is an 'insert' example; the same differences apply...
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
7
by: BillCo | last post by:
I need to Connect to an online mySQL database from Access using JET ODBC with no saved DSN. Anyone out there who as made this work and can give example of how it's done? I've seen lots of posts...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.