[SQLObject] DBMConnection not saving any data
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Mark M. <ma...@di...> - 2003-07-08 20:18:11
|
OK, I don't know if this is a dumb question or not - but I am trying to develop using the DBM connection for now, but when I try to create the tables, it creates the '.db' files but there is no data saved (i.e. they are 0 bytes in size). I assume I am doing something wrong. I'm also assuming this works on Win2K, with SQLObject 0.4, and that the DBM filesystem is actually supposed to be a persistent format? My code is as follows (note - I changed all my StringCols to Cols with sqlType set just to make sure that wasn't it): from SQLObject import * __connection__ = DBMConnection('db/', debug=1) class Customer(SQLObject): Contacts = MultipleJoin('Contact', orderBy=['LastName', 'FirstName']) CustomerName= Col(sqlType='VARCHAR(30)', default="") Street = Col(sqlType='VARCHAR(35)', default="") Suite = Col(sqlType='VARCHAR(35)', default="") City = Col(sqlType='VARCHAR(20)', default="") Province = Col(sqlType='VARCHAR(15)', default="") PostalCode = Col(sqlType='VARCHAR(7)', default="") PhoneNumber1= Col(sqlType='VARCHAR(20)', default="") FaxNumber = Col(sqlType='VARCHAR(20)', default="") class Contact(SQLObject): Customer = ForeignKey('Customer') LastName = Col(sqlType='VARCHAR(15)', default="") FirstName = Col(sqlType='VARCHAR(15)', default="") Title = Col(sqlType='VARCHAR(25)', default="") PhoneNumber1= Col(sqlType='VARCHAR(20)', default="") PhoneNumber2= Col(sqlType='VARCHAR(20)', default="") Notes = Col(sqlType='TEXT', default="") if __name__ == '__main__': Customer.createTable() Contact.createTable() Customer.new(CustomerName='Blow, Joe', City='Waterloo') c = Customer.new(CustomerName='Wankus Inc.', City='Waterloo') Contact.new(FirstName='Doctor', LastName='Evil', Title='The Bug Cahuna', Customer=c) print list(Customer.select()) print list(Contact.select()) I see the data printed fine, and the select statements work fine as well. It isn't saved to the file however. Do I have to close the connection or flush things somehow? -- Thanks, Mark. |