SQLite中的BLOB? [英] BLOB in SQLite?

查看:86
本文介绍了SQLite中的BLOB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个ID为AUTOINCREMENT且图像为BLOB的SQLite数据库.

I have created a SQLite database with an id AUTOINCREMENT and image BLOB.

现在,我想在图像列中插入图像.我是一个客观的c核心,并且一直在尝试各种方法,但是它们似乎没有用.我对MYSQl了解很多,但对SQLite却不了解,我似乎无法弄清楚.

Now, I want to INSERT a image in the image column. I am a big objective-c nube and have been trying all sorts of stuff but they don't seem to be working. I know lots about MYSQl, but not SQLite and I can't seem to figure it out.

我有 uploadImage (UIImage).我正在此处使用Matteo Bertozzi的SQLite包装器.这是在有人从手机上摘取图片后我得到的一些代码:

I have uploadImage (UIImage). I am using Matteo Bertozzi's SQLite wrapper here. Here's some of my code I have after someone picks an image off their phone:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    [picker.parentViewController dismissModalViewControllerAnimated:YES];

    uploadImage = image;

    NSData *dataForImage = UIImagePNGRepresentation(uploadImage);

    [database executeNonQuery:@"INSERT INTO process (image) VALUES (dataForImage)"]; 

}

再次感谢!

库尔顿

推荐答案

  • 语言是Objective-C,而不是C ++.:)
  • 通常,从潜在的内存使用和I/O角度来看,将大量图像推入SQLite数据库将效率很低.它将变慢并使用更多资源.最好将图像放入文件系统中,然后从SQLite数据库中引用文件系统.

    In general, shoving lots of images into a SQLite database is going to be inefficient, both in terms of potential memory use and I/O. It'll be slower and use more resources. Better to put the images into the filesystem and then refer to the filesystem from the SQLite database.

    这与 Blob数据类型有关?

    这篇关于SQLite中的BLOB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆