add read/write db function