Re: LibCurl 4 and SQLite 3 wrappers

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

When using SQLite to store Euphoria objects, do I need to sprint() the data before storing it, or does the wrapper handle the conversion of Euphoria objects back and forth?

It looks like sqlite_bind_blob() will store objects using compress() and sqlite_column_blob() will fetch them with decompress().

public procedure sqlite_bind_blob(atom db, atom stmt, integer param_index, object val) 
  integer ret 
  sequence val_string 
  atom val_addr    
     
  val_string = compress(val) 
  val_addr = allocate (length (val_string)) 
  poke (val_addr, val_string) 
       
  ret = c_func(xsqlite3_bind_blob,{stmt, param_index, val_addr, 
                  length (val_string), SQLITE_TRANSIENT}) 
   
  sqlite_last_err_no = ret 
  sqlite_last_err_desc = "" 
  if ret != SQLITE_OK then 
    sqlite_last_err_desc = sqlite_errmsg (db) 
    fatal (db, "sqlite_bind_blob()") 
  end if    
end procedure 
public function sqlite_column_blob(atom db, atom stmt, integer column_num) 
  atom addr, nBytes 
  sequence val_string 
       
  addr = c_func(xsqlite3_column_blob, {stmt, column_num - 1}) 
  if addr then 
    nBytes = c_func(xsqlite3_column_bytes, {stmt, column_num - 1}) 
    val_string = peek ({addr, nBytes}) 
    return decompress (val_string) 
  else 
    fatal(db, "sqlite_column_blob(): can't get data") 
    return -1 
  end if 
end function 

Curious, what benefit is there to storing serialized objects in the database? Wouldn't you be better served using text and number fields so you can query off them?

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu