开发者

What datatype should I use for storing large text files and binary data in SQLite in Rails

开发者 https://www.devze.com 2023-02-07 16:23 出处:网络
I need to store some binary files (spreadsheets) and some web pages in my table in SQLite DB in Rails. I know that storing files in the 开发者_运维问答DB isn\'t a good practice but in this case, the c

I need to store some binary files (spreadsheets) and some web pages in my table in SQLite DB in Rails. I know that storing files in the 开发者_运维问答DB isn't a good practice but in this case, the convenience outweighs all else since I only need to store files rarely. Thank you.


You should use the BLOB type for this purpose.


The binary data type maps to to the BLOB in SQLite. The size can be specified by using the limit parameter. Here's an example from an self.up method of a migration:

t.column :mystuff, :binary, :limit => 10.megabyte
0

精彩评论

暂无评论...
验证码 换一张
取 消