www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - sqlite_mismatch using etc.c.sqlite3

reply "Jacho Mendt" <jacho.mendt gmail.com> writes:
Hello everyone, I'm currently working on a prototype database 
system, but I'm kinda new to D and to sqlite3. The fragment of 
code that gives me problems looks like this:

extern(C) int myCallback(void *a_parm, int argc, char **argv,
char **column)
{
      return 0;
}



int new_entity(sqlite3* db)
{
	const(char)* sql="SELECT ID FROM ENTITY;";
	int result;
	result=sqlite3_exec(db,sql,&myCallback,null,null);
         writeln(result);
	if (SQLITE_OK!=result)
	{ return -1;}
         return 0;
}

sqlite3_exec here returns 21, wich is the code for 
SQLITE_MISMATCH. I know I'm doing something wrong, i just can't 
find what.
Jan 25 2014
parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Saturday, 25 January 2014 at 12:43:48 UTC, Jacho Mendt wrote:
 sqlite3_exec here returns 21, wich is the code for 
 SQLITE_MISMATCH. I know I'm doing something wrong, i just can't 
 find what.
I can't really see why that would be considering the explaination of that error: "This error occurs when there is an attempt to insert non-integer data into a column labeled INTEGER PRIMARY KEY. For most columns, SQLite ignores the data type and allows any kind of data to be stored. But an INTEGER PRIMARY KEY column is only allowed to store integer data." Might I suggest using a wrapper? https://github.com/bayun/SQLite3-D/blob/master/sqlite3.d You'll want to replace the import sqlite3_bindings to use the etc.c.sqlite3.
Jan 25 2014