mercredi 8 juillet 2015

Raspberry PI 2 - How to get file-access for c-program to write on disc

i am using Raspbian on a RPI2 and i tried to create/change a SQLite database from a C-Program.

here a little bit code:

static sqlite3 *db;
static char *zErrMsg    = 0;
//....
sqlite3_open(PATH_DATABASE, &db);
char *sql_statement = "CREATE TABLE IF NOT EXISTS myTable (datetime BIGINT, myVal BIGINT)";
sqlite3_exec(db,sql_statement, NULL, NULL, &zErrMsg);

sqlite3_close(db);

As IDE i use Eclipse CDT.

In Eclipse Debug-Mode and with executing the program by double click (in "sudo startx" mode), raspbian creates me a database file.

If i start my program via terminal (sudo /home/pi/test/myProgram) no database-file could be created.

Folder "test" and executable "myProgram" have both chmod 755 access. I searched a lot, found nothing that helps me.

Aucun commentaire:

Enregistrer un commentaire