Noel Frankinet wrote:
> 
> Narendran a écrit :
>> Dear Friends,
>>
>>
>>   I am in the process of forming a Generic API,(sql oriented and
>> BerkelyDB
>> and sister databases). In the process of integration ,i like to store a
>> Structure in Sqlite. 
>>
>>  as far as my knowledge SQLITE allows me to declare the column types
>> suppoted by the programming languare or say i am using blob . My
>> requirement
>> is i wish to store a structure in the SQLite column.
>>
>>   I am unable to form a sql statement to store the structure ,i am also
>> not
>> clear with whether i can have a strucure as column type.
>>
>> suggestions will be really helpful.
>>
>>  Thanking you,
>>  B.Narendran
>>   
> You will need to turn your c struct into a blob and store that blob.
> When retrieving the blob, you need a way to turn it back into your struct.
> Its releatively easy if your struct does not contains pointers.
> 
> Best wishes
> 
> -- 
> Noël Frankinet
> Gistek Software SA
> http://www.gistek.net
> 
> 
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [EMAIL PROTECTED]
> -----------------------------------------------------------------------------
> 
> 
> 

Dear Frankinet,

  Thanks for ur reply,

  I am unable to understand what u have said. I am having a structure and I
am converting in to a blob. This means i am supposed to remove the '\0' in
between the strucure and put a final '\0' (NULL) character . Blob need only
on e null character to terminate it.
   I tried to memcopy the structure elements and store them ,I can store but
i am unable to find a way to retrieve it back. 

 typedef  struct ethernetcard1
    {
      char port[10];
      char ipaddress[20];
      char mask[20];
      int bandwidth;
  }

what i tried is 

 char *buffer;
  int bufferlen;buffersize;
bufferlen = strlen(port)+strlen(ipaddress)+strlen(mask)+sizeof(int)+1;

memcpy(buffer,user.port,strlen(user.port);
buffersize = strlen(user.port);

memcpy(buffer,user.ipaddress,strlen(user.ipaddress));
buffersize += strlen(user.ipaddress);

and finally i included a NULL character to the buffer to make it as string
and i can insert in to a text field in sqlite column . I am unable to figure
out a way to retrieve it back if i am storing in this way or a blob type  I
think blob will be similar to this . 
 
 expecting ur valuable suggestion.

Thanking you,
Narendran 
-- 
View this message in context: 
http://www.nabble.com/Wish-to-store-a-C-structure-in-sqlite-column-tf2312254.html#a6441692
Sent from the SQLite mailing list archive at Nabble.com.


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to