Anthony, I tried db.mytable.import_from_csv_file([file object], null='')
from the web2py shell, but it gave me an error: OperationalError: near ")": syntax error In fact, trying to import from csv using the book's method does not work at all, although exporting works fine. Viniciusban, I'm inserting data through the database administation interface (filling out the form). I've also tried importing the CSV file through the administrative interface as well, where all blank spaces in the csv some out to empty strings (unless the field type is 'integer'). On Monday, July 23, 2012 10:47:24 PM UTC-7, viniciusban wrote: > > Yes, they are default settings. > > It's quite strange you get empty strings instead null (None, in Python). > > How are you inserting data into db? Are you using a SQLFORM or > my_table.validate_and_insert() or simply mytable.insert()? > > Do you get same results (blank values) inserting it from web2py shell > using simply mytable.insert()? > > -- > Vinicius Assef > > > > On Monday, July 23, 2012 5:58:19 PM UTC-4, Mark Li wrote: > > > > Aren't those the default values for a Field Contructor? I tried > > explicitly adding "notnull=False" and "required=False", and didn't > > set the default property, but empty values still come out as an > > empty string instead of None. > > > > On Monday, July 23, 2012 2:48:56 PM UTC-7, viniciusban wrote: > > > > As far as I know, let "notnull=False" and "required=False" for > your > > fields and don't set "default" property. > > > > > > > > On 07/23/2012 06:32 PM, Mark Li wrote: > > > Unfortunately the lambda method didn't work, Anthony. Any > other ideas > > > for having a None default for empty entries? > > > > > > > > > On a side note, if the 'integer' field type is used, then a > blank entry > > > results in a None. Don't know if that helps but it's something > I've noticed. > > > > > > On Monday, July 23, 2012 2:07:51 PM UTC-7, Anthony wrote: > > > > > > To enter a value of None, this might work: > > > > > > | > > > default=lambda:None > > > | > > > > > > Anthony > > > > > > On Monday, July 23, 2012 5:04:44 PM UTC-4, Anthony wrote: > > > > > > default=None means that no default is specified, not > that a > > > default value of None will be inserted. > > > > > > Anthony > > > > > > On Monday, July 23, 2012 5:02:33 PM UTC-4, Mark Li > wrote: > > > > > > I have a table defined in the following manner: > > > > > > db.define_table('songinfo', > > > Field('songtitle'), > > > Field('artist')) > > > > > > When I add an empty entry, or upload a CSV with > empty > > > values, I can only access those values with a > database call like > > > > > > songs = db(db.songinfo.artist=="").select() > > > > > > as opposed to > db(db.songinfo.artist==None).select() > > > > > > > > > The web2py book states that fields default=None, > but I'm > > > getting an empty string. Is there an appropriate > way to have > > > None instead of an empty string in the database? > > > > > > > > > -- > > > > > > > > > > > > > -- > > > > > > > > --