[wxPython] wxDb and wxDbTable will be implemented in wxPython ?

Thank you, David.
I'm very new to Python and wxPython (2 weeks), and I appreciate any help I
get (but Python is very easy to learn, and so it is wxPython). Using your
advices, I succeded to connect to mySQL db.
Please, if possible, send/give me some examples about displaying/printing
the records fetched from a sql db. I work on Windows (not Linux yet).
Thank you again,
Razvan

···

-----Original Message-----
From: David Beech [mailto:dbeech@bigpond.net.au]
Sent: Wednesday, September 12, 2001 5:16 AM
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] wxDb and wxDbTable will be implemented in wxPython?

Although it can be a little more difficult perhaps the best way is to
use ODBC and one way start is to get Marc Lemburg's mx tools from:

www.lemburg.com/files/python/eGenix-mx-Extensions.html

The tools are very good. You need mxBase and mxCommercial.
mxCommercial includes the ODBC drivers for many DBMS's and
works with Linux and Windows.

Whichever platform you use you will need to use the ODBC management
software to setup your database DSN's. For example use control panel
data sources ODBC for Windows and ODBCConfig for KDE on Linux.

An ODBC manager is part of Windows but you will need to install one
for Linux. I used unixODBC.

The example below runs on Linux and uses the unixODBC driver manager
to connect to a Postgres database but will work with any dbms that supports
Driverconnect. Connecting to any given database can be easy or not so easy
depending on how good the ODBC driver is. The driver is something that is
peculiar to the dbms. Each dbms should have odbc drivers available for it.
Postgres and MySQL both have drivers and I understand InterBase does also.

# Import the relevant bits from the mx package
import mx.ODBC.unixODBC

# Connect to the database, this must be setup via the driver manager
# config program
database = mx.ODBC.unixODBC.DriverConnect('DSN=gcdb;UID=david;PWD=mpypwd')

#Get a cursor (a data connection)
cursor = database.cursor()

#and execute an SQL statement
cursor.execute('select * from parts')

#fetch the first record/row
record = cursor.fetchone()

#and display it
#you can put this in wxPython listcontrol or a grid
#I have examples if you need them
for x in range(len(record))
    print "%s" % (record[x])

#print the rest of the rows prettily in an ASCII kind of way
mx.ODBC.print_resultset(cursor)

cheers,

David

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

PythonCard which sits on top of wxPython has a dbBrowser sample written by
Andy Todd that can display mySQL databases. It might give you some ideas
about how to accomplish what you want to do.

The latest PythonCardPrototype release is at:

See the readme.txt in the PythonCardPrototype\samples\dbBrowser directory
for more information.

ka

···

-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of ISA STL
HiEnd Razvan Andrei
Sent: Tuesday, September 11, 2001 8:50 AM
To: 'wxpython-users@lists.wxwindows.org'
Subject: RE: [wxPython] wxDb and wxDbTable will be implemented in
wxPython?

Thank you, David.
I'm very new to Python and wxPython (2 weeks), and I appreciate any help I
get (but Python is very easy to learn, and so it is wxPython). Using your
advices, I succeded to connect to mySQL db.
Please, if possible, send/give me some examples about displaying/printing
the records fetched from a sql db. I work on Windows (not Linux yet).
Thank you again,
Razvan

-----Original Message-----
From: David Beech [mailto:dbeech@bigpond.net.au]
Sent: Wednesday, September 12, 2001 5:16 AM
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] wxDb and wxDbTable will be implemented in
wxPython?

Although it can be a little more difficult perhaps the best way is to
use ODBC and one way start is to get Marc Lemburg's mx tools from:

www.lemburg.com/files/python/eGenix-mx-Extensions.html

The tools are very good. You need mxBase and mxCommercial.
mxCommercial includes the ODBC drivers for many DBMS's and
works with Linux and Windows.

Whichever platform you use you will need to use the ODBC management
software to setup your database DSN's. For example use control panel
data sources ODBC for Windows and ODBCConfig for KDE on Linux.

An ODBC manager is part of Windows but you will need to install one
for Linux. I used unixODBC.

The example below runs on Linux and uses the unixODBC driver manager
to connect to a Postgres database but will work with any dbms
that supports
Driverconnect. Connecting to any given database can be easy or not so easy
depending on how good the ODBC driver is. The driver is something that is
peculiar to the dbms. Each dbms should have odbc drivers available for it.
Postgres and MySQL both have drivers and I understand InterBase does also.

# Import the relevant bits from the mx package
import mx.ODBC.unixODBC

# Connect to the database, this must be setup via the driver manager
# config program
database = mx.ODBC.unixODBC.DriverConnect('DSN=gcdb;UID=david;PWD=mpypwd')

#Get a cursor (a data connection)
cursor = database.cursor()

#and execute an SQL statement
cursor.execute('select * from parts')

#fetch the first record/row
record = cursor.fetchone()

#and display it
#you can put this in wxPython listcontrol or a grid
#I have examples if you need them
for x in range(len(record))
    print "%s" % (record)

#print the rest of the rows prettily in an ASCII kind of way
mx.ODBC.print_resultset(cursor)

cheers,

David

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users