公告
财富商城
积分规则
提问
发文
2020-03-08 00:10发布
乱世女痞
i have some pictures and i want to store it in sqlite
what i need to do
For detail follow site: http://blog.developeronhire.com/create-sqlite-table-insert-into-sqlite-table/
<script type="text/javascript"> function createDatabase(){ try { if(window.openDatabase) { var shortName = 'db_edentiti'; var version = '1.0'; var displayName = 'Edentiti Information'; var maxSize = 65536; // in bytes db = openDatabase(shortName, version, displayName, maxSize); } } catch(e) { alert(e); } } function executeQuery($query,callback){ try { if(window.openDatabase){ db.transaction( function(tx){ tx.executeSql($query,[],function(tx,result){ if(typeof(callback) == "function"){ callback(result); }else{ if(callback != undefined){ eval(callback+"(result)"); } } },function(tx,error){}); }); return rslt; } } catch(e){} } function createTable(){ var sql = 'drop table image'; executeQuery(sql); var sqlC = 'CREATE TABLE image (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, image BLOB )'; executeQuery(sqlC); } function insertValue(){ var img = document.getElementById('image'); var sql = 'insert into image (name,image) VALUES ("sujeet","'+img+'")'; executeQuery(sql,function(results){alert(results)}); } <input type="button" name='create' onClick="createDatabase()" value='Create Database'> <input type="button" name='create' onClick="createTable()" value='create table'> <input type="button" name='insert' onClick="insertValue()" value='Insert value'> <input type="button" name='select' onClick="showTable()" value='show table'> <input type="file" id="image" > <div result></div>
There are two schools of thought
If the database is very large and the images are too, then the file system way is more performant.
If you just want something done quick, use a blob. It's ok, but doesn't scale as well.
最多设置5个标签!
For detail follow site: http://blog.developeronhire.com/create-sqlite-table-insert-into-sqlite-table/
There are two schools of thought
If the database is very large and the images are too, then the file system way is more performant.
If you just want something done quick, use a blob. It's ok, but doesn't scale as well.