segunda-feira, novembro 23, 2009

Short tutorial to migrate web2py database - model and data

Short tutorial

1. To export your sqlite database, use the shell:

db.export_to_csv_file(open('somefile.csv', 'wb'))


2.  create a empty postgresql database, and change
    db = DAL('sqlite://storage.sqlite')     

to   

    # db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or other DB
    db = DAL("postgres://user:password@localhost:5432/yournewdatabase")



3. and to import:

db.import_from_csv_file(open('somefile.csv', 'rb'))


--
Atenciosamente

--
=========================
Alexandre Andrade
Hipercenter.com

Nenhum comentário: