I have used sqlite in c++, python and now (perhaps) in C#. In all of these i have no idea how to insert a blob into a table. How do i store and retrieve a blob in sqlite?
相关问题
- Views base64 encoded blob in HTML with PHP
- SQL/SQL-LITE - Counting records after filtering
- What SQLite NuGet package do I need
- How to write the array into the sqlite database fo
- Groupwise MAX() on a subquery
You need to use sqlite's prepared statements interface. Basically, the idea is that you prepare a statement with a placeholder for your blob, then use one of the bind calls to "bind" your data...
SQLite Prepared Statements
Here's how you can do it in C#:
In C++ (without error checking):
That can be
SQLITE_STATIC
if the query will be executed beforeblob
gets destructed.This worked fine for me (C#):
No need for chunking. Just cast to a byte array.
I ended up with this method for inserting a blob:
For reading it back the code is:
Since there is no complete example for C++ yet, this is how you can insert and retrieve an array/vector of float data without error checking: