[Tutor] What to choose - database

Lloyd Kvam lkvam@venix.com
Wed, 12 Sep 2001 19:47:45 -0400


Danny Kohn wrote:
> =

> Hi.
> I am a total newbie having spent the last week to read a lot of stuff a=
bout Python, coming to think that it could be a good language for my prog=
ram project. My question is regarding databases. The application I want t=
o write does probably need some form of database support. It is very much=
 material to digest and I am a very slow reader so I would like to get so=
me advice which path that might be most successful or easiest.
> =

> By background is from 20 years ago when computers, even microcomputers,=
 had a control panel and you could single step them. The program language=
 was assembler. Have also done some Basic and also in nearer time some sm=
all tasks in Visual Basic.
> =

> Now, I have come to like the MySQL concept although I am not attached t=
o it (yet). Now I'm sure my questions seem unenlightened and they are but=
 that is what this list is about so here they are.
> =

> 1. It seems that I can do database access two ways, through the DB-API =
spec v2.0 or through ODBC (which I understand is also support in Linux). =
Is this a correct understanding?

YES
> =

> 2. If this is so, what way would be the best choice and why?
> =

ODBC gives you easy portability between SQL servers.  It also allows non-=
Python applications access to the database.  If you have any of these (e.=
g. SAS, Excel, Access) you will wind up doing the ODBC anyway.

The DB-API will give slightly better performance.  I normally use ODBC.

> 3. I need to be able to create tables from the program. But I have not =
found any way to do it. How to do this?

SQL create table commands.  Just pass them to the database using your int=
erface using ODBC or whatever.
> =

> 4. Does one run SQL to access tables from Python. If so, how is this do=
ne? If not, what does one do instead? Running through the API? But then, =
what does one do when one want to access the database(s) when the "specif=
ied" ways are inadequate?

For instance:
		DB.shared_conn=3DODBC.Windows.connect('shared',clear_auto_commit=3D0)
cursor =3D DB.shared_conn.cursor()
# Start with first Database found
cursor.execute("SHOW DATABASES")
DB.ds.fromCursor(cursor)

This gets a list of available databases into the DB.ds object.

> =

> H=E4lsningar / Regards                                 (\_/)  ))
> Danny Kohn                 Tel: +46 (0)708 140 300  =3D('.')=3D//  Miau=
!
> Systematik Consulting AB   ICQ: 1328817             ( ~~~ )/   Rrrrrui!=

> http://www.systematik.se   HAM: SM0NBJ              `w---w=B4
> =

> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- =

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582