Thanks, now that I've switched to an auto incremented pk all is fine.

On Nov 16, 2007 11:40 AM, Paul McNett <[EMAIL PROTECTED]> wrote:
> William Bryant wrote:
>
> > On Nov 15, 2007 3:57 PM, Paul McNett <[EMAIL PROTECTED]> wrote:
> >>
> >> William Bryant wrote:
> >>
> >> > Hello all,
> >> >
> >> > I've generated a very simple app with the class designer.  The app 
> >> > connects to
> >> > a MySQL database.  Queries work fine, editing and deleting records work
> >> > fine, but new records do not get inserted.
> >> >
> >> > I can insert records into the target table with a non-dabo python 
> >> > program.
> >> >
> >> > In the dabo app, I'm trying to insert by selecting "New Record" from
> >> > the "Actions"
> >> > pulldown, then selecting "Save Changes" from "Actions."  A traceback 
> >> > ends with
> >> > "No records updated" exception raised via 
> >> > self.BackendObject.noResultsOnSave
> >> > in dCursorMixin.py.
> >> >
> >> > I expect I've overlooked something pretty obvious; if so, please treat
> >> > me gently,
> >> > and many thanks!
> >>
> >> The first thing that comes to my mind is primary-key (pk) related. Is
> >> the pk on the MySQL side an integer set to auto-increment?
> >>
> >> If so, you need one set of property settings on the bizobj, and if not,
> >> you need another set.
> >>
> >> Also, can you please post the entire traceback you are getting?
> >> Hopefully it'll show a MySQL exception and we can figure out what is
> >> wrong from that.
>
>  > The primary key is indeed an integer, but it is not set to
> auto-increment.
>
>
> Okay, I believe that's your problem. Because you don't have your mysql
> table set to auto increment its primary key, you need to send a unique
> primary key. In Dabo, you do this by setting an appropriate entry in
> biz.DefaultValues. Such as:
>
> class MyBizobj(dabo.biz.dBizobj):
>   def initProperties(self):
>     self.DefaultValues["my_pk_field_name"] = self.getRandomKey
>
>   def getRandomKey(self):
>     import random
>     return random.randint(10000, 10000000)
>
>
> Obviously, you need a better way to get your primary key value, but it
> shows what you need to do. The better solution in your case, since you
> are using integer keys, is to set your MySQL table to auto-increment
> your keys.
>
>
>
>  > Below is the traceback; thanks so much for your help!
>  >
>  > Traceback (most recent call last):
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\lib\eventMixin.py",
>  > line 98, in raiseEvent
>  >     bindingFunction(event)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\lib\datanav2\Page.py",
>  > line 334, in onRequery
>  >     self.requery()
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\lib\datanav2\Page.py",
>  > line 362, in requery
>  >     ret = frm.requery(_fromSelectPage=True)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\lib\datanav2\Form.py",
>  > line 483, in requery
>  >     return self.super(dataSource)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\lib\autosuper\autosuper.py",
>  > line 176, in __call__
>  >     return method(*p, **kw)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\ui\uiwx\dForm.py",
>  > line 431, in requery
>  >     if not self.confirmChanges(bizobjs=bizobj):
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\ui\uiwx\dForm.py",
>  > line 184, in confirmChanges
>  >     self.save(dataSource=biz.DataSource)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\lib\datanav2\Form.py",
>  > line 53, in save
>  >     ret = super(Form, self).save(dataSource)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\ui\uiwx\dForm.py",
>  > line 342, in save
>  >     bizobj.saveAll()
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\biz\dBizobj.py",
>  > line 272, in saveAll
>  >     startTransaction=False, topLevel=False)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\biz\dBizobj.py",
>  > line 639, in scanChangedRows
>  >     func(*args, **kwargs)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\biz\dBizobj.py",
>  > line 325, in save
>  >     cursor.save()
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\db\dCursorMixin.py",
>  > line 1066, in save
>  >     saverow(self.RowNumber)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\db\dCursorMixin.py",
>  > line 1037, in saverow
>  >     self.__saverow(row)
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\db\dCursorMixin.py",
>  > line 1150, in __saverow
>  >     self.BackendObject.noResultsOnSave()
>  >   File
> "C:\Python25\lib\site-packages\dabo-0.8.1s-py2.5.egg\dabo\db\dBackend.py",
>  > line 108, in noResultsOnSave
>  >     raise dException.dException, _("No records updated")
>  > dException: No records updated
>
> Unfortunately, we don't tend to preserve the original traceback from the
> database backend.
>
> --
> pkm ~ http://paulmcnett.com
>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to