On 8/16/06, Mark Doukidis <[EMAIL PROTECTED]> wrote:
Hi all,

I am trying to create tables on the fly and populate them via
dAutoBizobj.initTable.

I cannot figure why this message is produced:
--------------------------------------------------------------------
Traceback (most recent call last):
  File "testapp.py", line 32, in ?
    main()
  File "testapp.py", line 29, in main
    dabo.biz.autoCreateTables()
  File "c:\dabo\dabo\dabo\biz\dAutoBizobj.py", line 47, in autoCreateTables
    biz.CreateTable()
  File "c:\dabo\dabo\dabo\biz\dAutoBizobj.py", line 283, in CreateTable
    self.new()
  File "c:\dabo\dabo\dabo\biz\dBizobj.py", line 615, in new
    self._onNew()
  File "c:\dabo\dabo\dabo\biz\dBizobj.py", line 941, in _onNew
    cursor.setDefaults(self.DefaultValues)
  File "c:\dabo\dabo\dabo\db\dCursorMixin.py", line 1124, in setDefaults
    raise ValueError, "Can't set default value for nonexistent field '%s'." % kk
ValueError: Can't set default value for nonexistent field 'owing'.
--------------------------------------------------------------------
from this code:
--------------------------------------------------------------------
import dabo
from dabo.db import dTable
import dabo.biz.dAutoBizobj as autobiz

def main():
    class Customer(autobiz):

        def initProperties(self):
            self.DataSource = "customer"
            self.KeyField = "id"
            self.RequeryOnLoad = False

        def getTable(self):
            tab = dTable(Name="customer", IsTemp=False)
            tab.addField(Name="id", IsPK=True, DataType="int", Size=2,
IsAutoIncrement=True)
            tab.addField(Name="code", DataType="int", Size=4,
AllowNulls=False, Index="idx_code")
            tab.addField(Name="name", DataType="string", Size=50,
Index="idx_name")
            tab.addField(Name="contact", DataType="string", Size=15)
            tab.addField(Name="owing", DataType="float", TotalDP=8,
RightDP=2, Size=8, Default=0)
            return tab

        def initTable(self):
            cols = ('code','name','contact','owing')
            return (cols, ((1,"Ken's Kayaks","Ken",100.55),(2,"Bob's
Bikes","Bob",234.56)))

    ci = dabo.db.dConnectInfo(DbType="SQLite", Database="test.db")
    conn = dabo.db.dConnection(ci)
    dabo.biz.setupAutoBiz(conn, (Customer,))
    dabo.biz.autoCreateTables()

if __name__ == "__main__":
    main()
--------------------------------------------------------------------

Any pointers welcome.

Mark Doukidis

Hey Mark,
I believe this is because there is a querk using SQLite. Dabo isn't
able to figure out the column types from the database when the table
is empty.
I will see if I can come up with a fix for this. I ran into the same
bug awhile ago. I'm not sure how long it will take since I don't have
much free time anymore. For the meantime you could install MySQL,
there shouldnt be any problems with that.


--
"Now that I am a Christian I do not have moods in which the whole
thing looks very improbable: but when I was an atheist I had moods in
which Christianity looked terribly probable."
 -C. S. Lewis

-Echo

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to