Postgresql是否可以对二进制数据执行多维数据集功能?

时间:2018-07-11 09:04:02

标签: python postgresql

我有一组图片功能(数据类型是python列表),如下所示,我使用pickle.dump列表到二进制文件并存储在表中。我想对功能进行多维数据集处理,但出现了错误,有没有一种方法可以对多维数据集(字节)进行处理。

[-0.07693052  0.13103333  0.03456296 -0.03198523 -0.11783121 -0.00864347
 -0.08238359 -0.11123394  0.11118498 -0.12523678  0.17256702 -0.10489954
 -0.21543087 -0.08727957 -0.07703612  0.24160105 -0.22249943 -0.15564784
 -0.00786823  0.05911971  0.14252234 -0.00624161  0.01735243  0.0219292
 -0.10636593 -0.33734819 -0.05135369 -0.07491996 -0.05320961 -0.02807039
 -0.04177326  0.02587014 -0.16554965 -0.06286186  0.03911624  0.02000083
 -0.02210705 -0.10491423  0.2021113  -0.00044226 -0.29604077  0.01300796
  0.07944702  0.2044373   0.13803098  0.00925212  0.03331146 -0.1774627
  0.12463985 -0.2000913  -0.00649202  0.13762167  0.08091226  0.07051353
  0.00342046 -0.10343951  0.04754291  0.10721903 -0.11586423 -0.03075701
  0.09388214 -0.03318139  0.01716307 -0.12743376  0.25524437  0.04930455
 -0.09589496 -0.20655566  0.10854267 -0.08835522 -0.1341148   0.07985611
 -0.10606824 -0.17955625 -0.26543319 -0.03198857  0.34081709  0.10754494
 -0.19059491  0.03278148 -0.07174835 -0.04601264  0.08218642  0.20006074
  0.02503737  0.06809284 -0.02955326 -0.03687159  0.25551286 -0.1125199
 -0.01698952  0.24861689  0.03379418  0.05015399  0.00976648 -0.02963495
 -0.07006045  0.08782617 -0.12364717 -0.03777558  0.04694367 -0.01261023
  0.00260606  0.13151917 -0.17752528  0.1014059  -0.04664776  0.02771331
  0.03564191 -0.02253933 -0.0823142  -0.05387688  0.11149541 -0.19149995
  0.16104887  0.15177445  0.09675844  0.07879145  0.14599283  0.07733928
  0.01200367 -0.01283191 -0.23660482 -0.01472425  0.1749115  -0.04009932
  0.06074818 -0.01628037]

以下是外壳显示的方式:

face_service_dev=# select cube(feature1) from device_devicephotomodel;
ERROR:  function cube(bytea) does not exist
LINE 1: select cube(feature1) from device_devicephotomodel;
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

和表的ddl如下:

CREATE TABLE public.device_devicephotomodel
(
    id bigint NOT NULL DEFAULT nextval('device_devicephotomodel_id_seq'::regclass),
    upload_time timestamp with time zone NOT NULL,
    take_photo_time timestamp with time zone NOT NULL,
    path character varying(24) COLLATE pg_catalog."default" NOT NULL,
    label integer NOT NULL,
    feature1 bytea,
    feature2 bytea,
    cluster_id integer,
    device_id integer,

并且我使用python psycopg2插入表,因为该功能我使用pickle.dumps()转换为二进制。

1 个答案:

答案 0 :(得分:0)

发现Django OMR支持数组see here

所以我只是更改了字段功能的数据类型并插入到PostgreSQL中,然后可以使用多维数据集功能。