store numpy array in mysql(在mysql中存储numpy数组)
问题描述
我的用例很简单,我对图像进行了某种操作,结果特征向量是一个形状为 rowX1000 的 numpy 对象(我的意思是说行号可以是可变的,但列号总是 1000)
My use case is simple, i have performed some kind of operation on image and the resulting feature vector is a numpy object of shape rowX1000(what i mean to say is that the row number can be variable but column number is always 1000)
我想在 mysql 中存储这个 numpy 数组.不对这个数组执行任何类型的操作.给定图像名称返回整个特征向量,查询将很简单.那么有没有什么方法可以存储数组(类似于一个封装数组的魔法容器,然后把它放在桌子上,检索时它检索魔法容器并弹出数组)
I want to store this numpy array in mysql. No kind of operation is to be performed on this array. The query will be simple given a image name return the whole feature vector. so is there any way in which the array can be stored (something like a magic container which encapsulates the array and then put it on the table and on retrieval it retrieves the magic container and pops out the array)
我想在 python 中做到这一点.如果可能的话,支持如何将数据放入 mysql 数据库的短代码片段.
I want to do this in python. If possible support with a short code snippit of how to put the data in the mysql database.
推荐答案
您可以使用 ndarray.dumps() 将其pickle 为字符串,然后将其写入BLOB 字段吗?使用 numpy.loads() 恢复它
You could use ndarray.dumps() to pickle it to a string then write it to a BLOB field? Recover it using numpy.loads()
这篇关于在mysql中存储numpy数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在mysql中存储numpy数组


基础教程推荐
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01