问题标签 [libpqxx]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1034 浏览

c++ - How to perform IN in sql query using pqxx in c++ for postgresql?

How to perform IN in sql query using pqxx in c++ for postgresql ? I have vector<long> of ids and I need to update every row in table students ( to set faculty_id to some new value). I want to avoid loop, new value (faculty_id) I get when I insert faculty with prepared INSERT statement. Is possible at all to pass so iterable structure or create prepared IN query using pqxx ?

$1 I have like vector of id of rows which I need to update

0 投票
0 回答
127 浏览

c++ - 如何更新unit_id并将其设置为NULL,unit id是来自单元表的外键

如何更新并将unit_id设置为NULL,unit id是外键,我需要设置为NULL

我试图更新部队并将 unit_id 设置为 NULL (我在 C++ 中的 pqxx 语句中将 NULL 而不是 0 )但是我得到了类似的错误

当我从 pgadmin 尝试时,我可以在部队中将 unit_id 设置为 NULL,但是 pqxx(从我尝试更新的 c++ 代码)将 NULL 转换为 0,如何解决这个问题?

0 投票
1 回答
968 浏览

c++ - 如何在几个小时后检查连接是否仍然有效?

我有一个工作线程,它永远运行,连接到 postgresql 数据库(在 c++ 中使用 libpqxx)

如何在几个小时后检查连接是否仍处于活动状态,例如,如果我同时重新启动 postgre 服务器(工作线程仍在运行且未重新启动),当我尝试执行新查询时,我应该检查它是否仍然有效并重新连接如果它不是。如何知道它是否还活着?

0 投票
2 回答
1150 浏览

postgresql - pqxx byteA 和 binaryString 奇怪的数据读取

我在使用 PostGreSQL 数据库和一些加密数据时遇到了一些问题。我使用河豚算法加密字符串,获得二进制数据作为回报。这个二进制文件可以包含 \0 和一些其他的 scape 序列。

我以这种方式存储数据:

然后我这样读:

问题是,有时,数据可以完美返回,但在其他情况下,数据会正确返回,之后会出现一些垃圾。关于我应该修改写入/读取的方向以避免这种奇怪的数据被添加到我的加密字符串中的任何线索?

我做的另一个尝试是以这种方式存储数据:

结果相同。

编辑:根据要求,做了一些日志研究:我正在研究这个值:

并将它们设置为

奇怪的狗屎是..我通过再次创建相同的变量使用 $5 和 $6 搜索得到了正确的行

但是如果我尝试打印我之前显示的字符串:

这就是我得到的(3次尝试):

随着更多的尝试,一切都会继续改变。我最终可以将正确的“”放入第一个属性中。在第一次尝试时正确显示的属性将始终正确显示。

0 投票
0 回答
1721 浏览

c++ - 未定义对“pqxx::result::begin() const”的引用

我正在尝试编译一段简单的代码,该代码使用 centos 6.3 上的 libpqxx 库从数据库中选择多行。

我收到以下链接器错误:

ASP:/root/test/libpqxx_folder$ g++ -g libpqxx_select_from_table.cpp -L/usr/lib64 -lpqxx -lpq -o 选择 libpqxx_select_from_table.cpp: 在函数'int main(int, char**)'中: libpqxx_select_from_table.cpp: 21:警告:不推荐将字符串常量转换为“char*”/tmp/cc0bFRAY.o:在函数main': /root/test/libpqxx_folder/libpqxx_select_from_table.cpp:30: undefined reference topqxx::result::begin() const'/root/test/libpqxx_folder/libpqxx_select_from_table.cpp:31:未定义引用pqxx::tuple::operator[](int) const' /root/test/libpqxx_folder/libpqxx_select_from_table.cpp:32: undefined reference topqxx::tuple::operator const' /root/test/libpqxx_folder/libpqxx_select_from_table.cpp:33: 未定义引用pqxx::tuple::operator[](int) const' /root/test/libpqxx_folder/libpqxx_select_from_table.cpp:34: undefined reference topqxx::tuple::operator const' /root/test/libpqxx_folder/libpqxx_select_from_table.cpp:35: 未定义引用pqxx::tuple::operator[](int) const' /tmp/cc0bFRAY.o: In functionbool pqxx::field::to, std::allocator > >(std::basic_string, std::allocator >&) const': /usr/local/include/pqxx/field.hxx:190: 未定义对pqxx::field::c_str() const' /usr/local/include/pqxx/field.hxx:191: undefined reference topqxx的引用::field::is_null() const' /usr/local/include/pqxx/field.hxx:192: 未定义对pqxx::field::size() const' /tmp/cc0bFRAY.o: In functionconst_result_iterator'的引用': /usr/local/include/pqxx/result.hxx:334: 未定义对pqxx::tuple::tuple(pqxx::result const*, unsigned long)' /tmp/cc0bFRAY.o: In functionbool的引用pqxx::field::to(int&) const': /usr/local/include/pqxx/field.hxx:119: 未定义引用pqxx::field::c_str() const' /usr/local/include/pqxx/field.hxx:120: undefined reference topqxx::field::is_null() const' /tmp/cc0bFRAY.o: 在函数bool pqxx::field::to<float>(float&) const': /usr/local/include/pqxx/field.hxx:119: undefined reference topqxx::field::c_str() const' /usr/local/include/pqxx/field.hxx:120: 未定义引用 `pqxx::field::is_null() const' collect2: ld 返回 1 个退出状态

在此先感谢您的帮助!

0 投票
1 回答
207 浏览

c++ - C++ 以编程方式将字符串编码为字符串文字

我正在尝试将某些用户输入的文本保存到数据库中,我将如何编码这些值?我是 C/C++ 的 n00b,我的 google fu 技能有问题..

我正在使用 libpqxx 并尝试做类似的事情

但是当 userInput 类似于

我的插入会失败。谢谢你的帮助。

0 投票
1 回答
322 浏览

c++ - C ++ postgis准备语句失败,几何无效

我正在使用 libpqxx 和准备好的语句,当我尝试以编程方式插入时它失败并出现错误“无效几何”,但我可以通过 sql 提示符执行相同的插入。我错过了什么吗?我试图在prepare语句调用中转义'但同样的错误

我也试过

输出:

如果我进入 sql 提示符,我可以运行它,它会插入

0 投票
1 回答
847 浏览

c++ - 如何从 pqxx 调用重载的远程过程

如何从 pqxx 调用重载的远程过程?

程序例如:

C++ 代码:

如何从 C++ 代码中调用“foo(num integer)”?例如,“ans”中的所需结果“int”。

psql.exe 输出:

选择 foo(1); 返回“int”

选择 foo("测试"); 返回“文本”

提前致谢。

0 投票
0 回答
227 浏览

ubuntu - 无法在 64 位系统上使用 libpqxx 编译我的 PHP-CPP 扩展

我迁移到 64 位 Ubuntu,现在我无法编译我的扩展。在 32 位上它工作得很好。有人知道是什么问题吗?谢谢你。我有这个错误报告。

0 投票
0 回答
533 浏览

c++ - pqxx::pipeline 是否支持准备好的语句

我们可以在里面执行准备好的语句(参数化查询)pqxx::pipeline,我们可以插入普通的 sql 语句,如:

SELECT * FROM table

但是我们可以做下面给出的事情吗

谢谢