I'm searching in the archives of this list for answers about my problem =
but maybe somebody can give me a hand.
I'm trying to build a small application just to run a select statement =
on an oracle database an show the results in a grid. I'd already read =
the wxgrid manual and wxPyGrid documentation, I'd see the dbBrowser2 =
code and used some pieces from it but I can't get it working.
=20
This is the code I have, I changed some database "secrets"
=20
#!/usr/bin/python
=20
"""
__version__ =3D "$Revision: 1.5 $"
__date__ =3D "$Date: 2004/04/30 16:26:12 $"
"""
=20
from PythonCard import model
import cx_Oracle
import string
from wxPython.wx import *
from wxPython.grid import *
from dbTable import DBTable
=20
class MyBackground(model.Background):
=20
def on_initialize(self, event):
# if you have any initialization
# including sizer setup, do it here
self.components.ApeTxtFld.setFocus()
pass
=20
def on_BusBut_mouseClick(self, event):
self.statusBar.text =3D "Conectando ..."
db =3D cx_Oracle.connect("user/password@TNSName")
self.statusBar.text =3D "Conectado"
## selectedTable =3D self.components["ApeTxtFld"].stringSelection
dbc =3D db.cursor()
arg_ =3D string.strip(self.components.ApeTxtFld.text)
dbc.execute("""
select column_1,
column_2
from table
where table.column_x =3D 'A' and
table.column_y =3D :arg""",
arg =3D arg_)
##rows =3D dbc.rowcount
info =3D dbc.fetchall()
gridDefn=3D{'name':'myGrid', 'type':'Grid'}
gridDefn['position']=3Dself.components.myGrid.position
gridDefn['size']=3Dself.components.myGrid.size
gridDefn['size']=3Dself.components.myGrid.size
del self.components[gridDefn['name']]
self.components[gridDefn['name']]=3DgridDefn
self.components.myGrid.SetColLabelValue(0, "Empleado")
self.components.myGrid.SetColLabelValue(1, "Nombre")
self.dbTable=3DDBTable(=BF?=BF?=BF?=BF?) <-- here is where I =
have problems, I used cursor, argument but no data shown
self.components.myGrid.SetTable(self.dbTable)
self.components.myGrid.AutoSizeColumns()
self.components.myGrid.AdjustScrollbars()
=20
=20
if __name__ =3D=3D '__main__':
app =3D model.Application(MyBackground)
app.MainLoop()
=20
=20
|