Re: Python and Databases
I'm surprised this hasn't been brought up thus far.... I use it on multiple
databases and multiple platforms. I can move applications from one platform to
another without modifications.
I have found the most practical (and portable) method of accessing databases is
with the dbi/odbc that comes with python. Not as fast as direct access and it
requires you to load and set up an ODBC data source for each DB server and Access
DB but.... the benefits far outweigh the speed issues.
I have migrated entire applications from one DB to another without with minimal
code changes. As an application matures or the database grows I move the data to a
more robust database server.
I have situations where I am accessing four (4) different data base engines within
the same program without having to remember the different syntax for each database
driver... I access all of them in the same manner! That is probably the biggest
benefit. Less training, fewer bugs, and better understanding across multiple
The following example would work for any of the four databases listed.
import dbi, odbc
fs_db = odbc.odbc('MSS-Flex Reports/mylogin/mypasswd') # Proprietary Fourth
Shift Manufacturing DB
mysql_db = odbc.odbc('mysql_odbc_db/mylogin/mypasswd') # web server, I don't
even know the location
postgres_db = odbc.odbc('postgres_odbc_db/mylogin/mypasswd') # my postgres
access_db = odbc.odbc('access_odbc_db') # one of our many MS Access databases
that seem to proliferate.
cur = postgres_db.cursor()
sql = "select field1,field2, field3 from mytable where field1 = 'myname';"
list = cur.fetchone()
for f1,f2,f3 in list:
cur = None
postgres_db = None
Geraldo Lopes de souza wrote:
> ... you have just one choice: the mxODBC package.
> It looks like a great package , it worths the price, but with java for
> example, I get more much more ( in library terms) for less.
> ... To increase this the python community needs a standard ODBC library in the
> ... I know there is the DB API but we need ODBC.
> ODBC is the standard way of communicating with databases, if you create a
> database the first thing you need is an odbc driver to make the existing
> applications to talk with your database.
|All times are GMT. The time now is 06:44 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.