我有一些照片,我想将它存储在sqlite
中我需要做什么
答案 0 :(得分:1)
有两种思想流派
如果数据库非常大且图像太大,那么文件系统的方式会更高效。
如果您只想快速完成某项操作,请使用blob。没关系,但也没有扩展。
答案 1 :(得分:1)
详情请点击网站: 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>