Over the past week I've experimented with several options (I'm moving from sqlite to mysql on python anywhere) and here's what worked for me (and hope this helps others) ...
1. Export all data in CSV format
a. open console and navigate to the web2py folder
b. start web2py in interactive console mode with:
python web2py.py -S your_app_name -M –P
c. export data in csv format with:
db.export_to_csv_file(open('your_app_name_export.csv', 'wb'))
[this stores the file in the root of the web2py directory]
d. exit web2py interactive console mode with:
exit()
2. Prepare web2py application for new database and create new database
a. in console, navigate to application folder
b. backup existing SQLite database (and corresponding .table files) with:
cp -r databases databases_bak
c. create empty databases folder with:
rm -r databases
mkdir databases
d. change DAL connection string in app to:
db = DAL('mysql://user_name:pass...@mysql.server/database_name')
[for pythonanywhere, the database_name is in the form user_name$database_name]
e. create new empty mysql database schema (from control panel in pythonanywhere or mysql command prompt)
3. Generate database tables and load data
a. start web2py in interactive console mode with:
python web2py.py -S your_app_name -M –P
[this will execute the models and generate the mysql database tables and the .table files in the database directory]
c. import data in csv format with:
db.import_from_csv_file(open('your_app_name_export.csv', 'rb'))
db.commit() # this is missing from some of the other instructions but is required
d. exit web2py interactive console mode with:
exit()