问题标签 [libpq]
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.
c++ - 从 C++ 程序执行时 psql \copy 命令错误
从 c++ 程序运行命令时出现此错误。
从 psql 提示符运行相同的命令时,它可以正常工作。
我做错了什么?
sql - 结合嵌入式 SQL 和 libpq 的功能
我用 C 语言编写了一个程序,它定期将 PostgreSQL 数据库中的变量轮询到主机变量中并监听来自数据库的通知。我想知道是否有一种解决方案可以让我 1. 使用嵌入式 SQL (ECPG) 听取来自数据库的通知或 2. 一步从 libpq 命令 PQexec 中选择 INTO 主机变量,而无需连续选择和解析字符串 - 即具有与 SELECT INTO(多个主变量)相同的功能。
现在,我必须设置两个连接,一个通过 EXEC SQL 来实现 SELECT INTO 功能,另一个通过 libpq 来创建一个连接指针,稍后 PQnotifies 用它来监听通知。该程序目前可以运行,但是必须将两个连接都设置到同一个数据库似乎是多余的。
c++ - 在 VS 2012 项目中使用 libpq (PostgreSQL) 库
我正在使用带有 Windows 7 x64 的 VS 2012。我的朋友为我写了使用 libpq 的 C++ 类:
每次尝试构建项目时,我都会收到 LNK2019 错误。screenshot我安装了 postgres 并加载了一些项目属性的路径:screenshot 我希望你能给我一个快速指南,如何让他的代码在我的项目中工作。
postgresql - libpq,带参数插入
我想知道我是否可以使用 libpq 直接从 C/C++ 进行参数化查询,而不是使用字符串,如果这个代码看起来像什么?
谢谢。
c++ - PQprepare 和 PQexecPrepared 用法
希望有人可以帮助我使用 PQprepare 和 PQexecPrepared。我确定我一定有什么问题,但我尝试的任何方法似乎都不起作用。
我正在尝试使用准备好的查询插入表中,但我不断收到此错误
ERROR: invalid input syntax for integer: "50.2000008"
这是我将 Oid 设置为 701 (float8) 的纬度值,但它说它是一个整数。我是完全错过了什么还是有什么不对劲的地方?
\d 数据加号
谢谢,
标记
postgresql - PostgreSQL、libpq/C、更新参数
我可以通过有一些弱点的字符串操作来更新表中的记录。
所以,现在我尝试使用参数进行更新,但这并没有像我想象的那样进行。
值 1 和 4 是整数,值 5 是不适合 const char 数组的两倍。
我只用字符串尝试相同的方法,它可以工作。
如果我必须将数字转换为看起来不合逻辑的字符串。
如何正确执行此操作?
c - 结构类似于 PostgreSQL 中 MySQL 的 MYSQL_ROW?
我最近从一个网站下载了一个源包,上面提到它与 PostgreSQL 和 MySQL 数据库兼容。
我尝试使用 MySQL 在 Linux Debian 机器上进行编译,它工作正常。然而我们的需求现在已经改变了,我们需要让它与 PostgreSQL 一起工作。
但是,当我编译时,它似乎不兼容。我猜从来没有用PGSQL测试过。开发人员也没有支持:(
原因:
现在 DB_ROW 定义如下:
其中未为 PGSQL 定义:
我尝试在 PostgreSQL 中搜索类似的结构,但似乎实现不同: http ://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html
我可以使用它,但这样做会使源代码特定于 PGSQL。
PGSQL中是否有类似的结构?
谢谢
c++ - 在 C++ 代码中处理 PL/pgSQL 函数的消息
我正在 PL/pgSQL 函数中运行计算,并且我想在我的 C++ 代码中使用该计算的结果。最好的方法是什么?
我可以将该结果插入表格并从那里使用它,但我不确定最佳实践的效果如何。另外,我可以向stderr
with发送消息,RAISE NOTICE
但我不知道是否可以在我的代码中使用该消息。
c++ - PostgreSQL: cancel query from C/C++ program
I'm using PostgreSQL 8.3, and writing a program in C++ that uses the libpq
API. I execute commands asynchronously with the PQsendQuery()
function. I'm trying to implement a timeout processing feature. I implemented it by calling PQcancel()
when the timeout expires. I tested it with a query that returns 100 000 rows (it lasts about 0.5 s) with a timeout of 1 ms, and found that instead of cancelling the command, PQcancel()
blocks until the server finishes execution, then returns with a successful query.
I understand that the documentation says that even with a successful cancel request the query may still be executed. My problem is that PQcancel()
blocks my thread of execution, which is not acceptable because I use asynchronous processing (using the Boost Asio framework) so my program, which may have other tasks to do other than executing the SQL query, runs only on one thread.
Is it normal that PQcancel()
blocks? Is there any way to make a non-blocking cancel request?
c - 关于windows中使用PQconnectdb()连接pq服务器时的认证
我在我的win7笔记本电脑上安装了postgresql9.2.4,并编写了一个简单的程序来测试我的vs2008中的连接。代码在这里:
运行后显示有关身份验证失败的错误。我知道这是密码的问题,应该是md5加密的。所以我在google上搜索。这个问题几乎没有问题。我在libpq文件夹中找到了一个名为“md5.h”的头文件,并有一个名为“pg_md5_hash”的函数",我试过了,但出现了很多链接错误。谁能给我一些建议?谢谢。