1

我有一个定义如下的 PostgreSQL 表:

                    Table "public.dm_metadata"
   Column   |            Type             |       Modifiers        
------------+-----------------------------+------------------------
 id         | character varying(60)       | not null
 insertedat | timestamp without time zone | not null default now()
 metadata   | hstore                      | 
Indexes:
    "dm_metadata_pkey" PRIMARY KEY, btree (id, insertedat)
    "dm_metadata_metadata_idx" gist (metadata)

谁能给我一个示例,说明如何使用 libpqxx 和准备好的语句将数据插入和选择到该表中?

具体来说,我对以下查询感兴趣:

INSERT INTO dm_metadata(id, metadata) VALUES ('werwer', '"a" => 1234');
INSERT INTO dm_metadata(id, metadata) VALUES ('werwer', '"a" => 1234, "b" => "hello"');
SELECT metadata FROM dm_metadata WHERE metadata @> '"a"=>1234';
SELECT metadata FROM dm_metadata WHERE metadata @> '"a"=>1234,"b"=>"hello"';
4

0 回答 0