I am using import csv option to insert records in the database. When I use the csv file from the web application, then a single record is inserted in the database with all the records being updated properly as per the headers.
But If I try to use "import_from_csv_file" outside the web2py, it inserts multiple records in the database. This seems to be an bug to me.
Code for updating db outside web2py
libraryPath = r'D:\web2py'
dbPath = r'D:\web2py\applications\testapp\databases'
import sys
sys.path.append(libraryPath)
from gluon import DAL
db = DAL('sqlite://storage.sqlite',folder=dbPath,auto_import=True)
table = db['person']
file = r'D:\file.csv'
table.import_from_csv_file(file)
db.commit()
On using the same file (csv file) using the web2py, it works as expected, code :-
file = request.vars.csvfile.file
table.import_from_csv_file(file)
Can some one please comment on this behavior, what am I missing here?
-Sarbjit