Changes between Version 11 and Version 12 of S3/DataImportCLI


Ignore:
Timestamp:
06/13/14 11:55:49 (7 years ago)
Author:
MattS
Comment:

syntax highlighting

Legend:

Unmodified
Added
Removed
Modified
  • S3/DataImportCLI

    v11 v12  
    66
    77Start the web2py CLI with the Eden data model environment:
    8 {{{
     8{{{#!python
    99python web2py.py -S eden -M
    1010}}}
    1111
    1212Override authorization:
    13 {{{
     13{{{#!python
    1414auth.override = True
    1515}}}
    1616
    1717Define the target resource:
    18 {{{
     18{{{#!python
    1919resource = s3db.resource("project_activity")
    2020}}}
    2121
    2222Import data:
    23 {{{
     23{{{#!python
    2424success = resource.import_xml(open("filename.csv", "rb"),                   # CSV format requires file handle, XML accepts filename
    2525                              format="csv",                                 # "xml", "json" or "csv"
     
    3131
    3232See errors (error message and error tree are returned in any case, even with ignore_errors=True):
    33 {{{
     33{{{#!python
    3434print success                 # prints a JSON message with the error message and the JSONified error tree
    3535print resource.error          # prints the error message
     
    3939
    4040Do not forget to commit the import (if you want to keep it):
    41 {{{
     41{{{#!python
    4242db.commit()
    4343}}}
    4444
    4545If you were only testing (e.g. to see validation errors), and now want to discard the import, you can either leave the shell without calling {{{db.commit()}}} - or you do an explicit:
    46 {{{
     46{{{#!python
    4747db.rollback()
    4848}}}