El 09/08/13 12:08, Paul McNett escribió:
On 8/8/13 1:39 PM, Ricardo Aráoz wrote:
Hi, I have this business object connected to a sqlite database. On pressing a
button
I want to connect to a new user selected database and replace the contents of
the
original database with the selected one.
So I create a temporary connection, and temporary business object in order to
get
the data set (ds) of the selected database. Then deleteAll() the records of the
original business object and append the new data set to the original business
object.
Right now I was expecting to have a copy of the selected database in my original
database but all I get is an empty table.
Note: the database has only one table (Tarjetas) and both tables, the original
one
and the user selected one are equal (except the data). I use the same business
class
(TarjetasBizobj) to create both business objects, bizTjtas and bizCargar, just
with a
different connection).
Anyone knows what I'm doing wrong?
------------------------- Code
-----------------------------------------------------------
def onCargarArchivo(self, evt):
nombreDB = dabo.ui.getFile('db',
message='Elija una base de datos',
defaultPath='db',
multiple=False)
if nombreDB:
ci = dabo.db.dConnectInfo(DbType='SQLite')
ci.Database = os.path.join('db', nombreDB)
try:
conn = dabo.db.dConnection(ci)
except dException.DBFileDoesNotExistException:
dabo.ui.exclaim(title='Atención',
message=('No me pude conectar con la base\n'
'No he cargado ningún archivo'))
return
else:
bizCargar = self.Application.biz.TarjetasBizobj(conn)
ds = bizCargar.getDataSet()
bizTjtas = self.Form.getBizobj(dataSource='Tarjetas')
bizTjtas.deleteAll()
bizTjtas.appendDataSet(ds)
self.Form.save(dataSource='Tarjetas')
self.Form.requery(dataSource='Tarjetas')
self.Form.GridTarjetas.refresh()
Did you intend for the else block to be part of the try block or part of the if
block?
I intended it to run after the try block if no exception was raised.
Anyway I've tried it without the try/except stuff (and without the
exclaim stuff) and same results. It would seem that it works up to the
deleteAll() (because the table is actually emptied) but then the
appendDataSet() does not get done.
I'm certain I'm doing something wrong here but can't find up what it is.
Cheers
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]