adodb with mysql - connection string syntax for filepath

J. Cliff Dyer jcd at sdf.lonestar.org
Tue Sep 18 01:21:19 CEST 2007


Mridula Ramesh wrote:
> Dear all,
>
> Hi. I am not very tech-savvy so please pardon me if this is a stupid
> question: so far I have been googling for about 4 days to find help
> for this, so now I am desperate! :)
>
> How do you use adodb with mysql to connect to a file that is on your
> machine?
>
I'm not quite sure what you mean by this.  MySQL won't connect you to a
file on your machine.  It will connect you to a database server, which
will possibly access files on your machine, but could just as easily
access an in-memory database, that isn't stored in any files.

I've also never worked with adodb, but if you use MySQLdb, you do the
following:

import MySQLdb as db

cur = db.connect(host='127.0.0.1', #or whatever your hosts address is
                 user=username,
                 passwd=password,
                 db=database).cursor()
cur.execute('SELECT * FROM table')
cur.fetchall()

If adodb is dbapi 2 compliant, it may be as simple as s/MySQLdb/adodb/

> Also, could you please recommend to me a good resource to learn more
> about classes and modules from? i don't understand half of the _init_
> business that many sites mention. (This *is* something even a newbie
> needs to learn, right?)
>
Try this chapter from Diving into Python:

http://www.diveintopython.org/object_oriented_framework/defining_classes.html
> Thank you!
>
> M.R.S.
Cheers,
Cliff



More information about the Python-list mailing list