how to fetch splite3 blob data

6 ビュー (過去 30 日間)
xi 2019 年 3 月 22 日
編集済み: Bob S 2020 年 11 月 5 日
sqlite() and fetch() function only works for one of these data types: double, int64, or char, But not for blob binary data chunk. I have two possible solutions:
  1. Use python to fetch the data of blob type and store in dataframe, but need to find a way to convert dataframe to structured data in matlab.
  2. "The sqlite object provides limited Database Toolbox™ functionality. For full functionality, create a database connection to the SQLite database file using the JDBC driver. To use the JDBC driver, close the SQLite connection and create a database connection using the URL string". But I cannot figure out how to do it.
Any suggestions?

回答 (1 件)

Bob S
Bob S 2020 年 11 月 5 日
編集済み: Bob S 2020 年 11 月 5 日
You can access sqlite database tables, and BLOBs, using the Python interface:
>> dbFileName = 'myDatabase.db';
>> tableName = 'myTable'
% Say the field name is data and there is an id field whos value we're after is 300
>> sql = py.importlib.import_module('sqlite3');
>> conn = sql.connect(dbFileName);
>> cur = conn.cursor()
>> query = 'SELECT data FROM myTable WHERE id=300';
>> cur.execute(query);
>> res = cur.fetchone();
% The above returns a Python tuple containing the id and the blob. This gets you the data:
>> data = res{2}.uint8;


Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by