When I wanted to save data with NAO, it was surprisingly easy.
OS X El Capitan 10.11.3 Choregraphe 2.1.3.3 SQLite version 3.8.10.2
Python Script You can leave the box at the default.
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
#put initialization code here
pass
def onUnload(self):
#put clean-up code here
pass
def onInput_onStart(self):
import sqlite3
appId = self.packageUid()
qi.path.setWritablePath("/Users/{User name}/Desktop/dev/nao/data_files") #Specify any location
dbpath = qi.path.userWritableDataPath(appId, "sample.db")
self.logger.info(dbpath)
conn = sqlite3.connect(dbpath)
c = conn.cursor()
c.execute('''CREATE TABLE shop (id INTEGER PRIMARY KEY, name TEXT , price INTEGER)''')
c.execute("INSERT INTO shop (name, price) VALUES ('hogehoge',100)")
conn.commit()
conn.close()
self.onStopped()
def onInput_onStop(self):
self.onUnload() #it is recommended to reuse the clean-up as the box is stopped
$ pwd
/Users/{User name}/Desktop/dev/nao/data_files/data/.lastUploadedChoregrapheBehavior
$ sqlite3 sample.db
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> .table
shop
sqlite> select * from shop;
1|hogehoge|100
I was able to register.
.lastUploadedChoregrapheBehavior
to chmod 777
.It seems that CSV package, JSON package, ElementTree package can also be used.
Recommended Posts