标签: pg

Node.js - PostgreSQL - 无法确定参数 $1 错误的数据类型

我正在尝试使用 node.js npm 包创建 PostgreSQL 准备好的语句pg。但是,我不断收到错误:

无法确定参数 $1 的数据类型

 function promiseQuery(sql, values) {
    return new Promise(function(resolve, reject) {
        pool.query('select $1 from workers', ['name'], function(err, result) {
            if (err) {console.log(err); reject(err)}
            else resolve(result.rows);   
        })
    });
}
Run Code Online (Sandbox Code Playgroud)

在数据库中,该name字段设置为 type text not null

我也尝试了pg-promise,但也没有成功。

javascript postgresql node.js pg pg-promise

7
推荐指数
1
解决办法
1万
查看次数

pg_restore 错误:函数 raise_err(未知) 不存在

我使用 pg_dump 和 pg_restore 对数据库进行每日备份,这些备份在我推送更新后最近停止工作。

我有一个函数validate_id,它是一个Case/When语句,可以快速检查一些存在完整性问题的数据。看起来像这样:

CREATE OR REPLACE FUNCTION validate_id(
    _string text,
    _type type
) RETURNS boolean AS
$$
SELECT
    CASE WHEN (stuff) THEN TRUE
    WHEN (other stuff) THEN TRUE
    When (more stuff) THEN raise_err('Not an accepted type, the accepted types are: x y z')
ELSE FALSE
$$
LANGUAGE SQL;
Run Code Online (Sandbox Code Playgroud)

由于我添加了此功能,当我使用此命令转储时:

pg_dump -U postgres -h ipaddress -p 5432 -w -F t databaseName > backupsfolder/databaseName.tar

当我使用这个命令时:

pg_restore -U postgres -h localhost -p 5432 -d postgres -C …

postgresql pg-dump pg-restore pg

7
推荐指数
1
解决办法
2218
查看次数

如何将数据从我的生产数据库传输到heroku中的临时数据库?

我正在尝试将数据从我的生产数据库传输到我的暂存数据库但没有成功.

我正在关注heroku的文档:http://devcenter.heroku.com/articles/pgbackups#transfers

这些是我运行的命令......

$ heroku addons:add pgbackups --remote staging
$ heroku addons:add pgbackups --remote production
$ heroku pgbackups:capture --remote production
$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging
Run Code Online (Sandbox Code Playgroud)

这就是我得到的信息......

Usage: heroku pgbackups:restore [<DATABASE> [BACKUP_ID|BACKUP_URL]]

restore a backup to a database

if no DATABASE is specified, defaults to DATABASE_URL and latest backup
if DATABASE is specified, but no BACKUP_ID, defaults to latest backup
Run Code Online (Sandbox Code Playgroud)

看来我拼错了,但我无法弄清楚.

我也尝试使用应用程序名称而不是远程的相同命令...

$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging
Run Code Online (Sandbox Code Playgroud)

但我收到相同的消息,没有实际转移. …

ruby database ruby-on-rails heroku pg

6
推荐指数
1
解决办法
2455
查看次数

Postgres - "pg"gem的最后一个版本0.14.0给出了错误

我更新了包含pg gem的bundler,我收到了错误

An error occured while installing pg (0.14.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.0'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)

我在rubygems.org上检查了这个gem ,今天(6月23日)发布了这个版本.我不知道为什么,但版本不能正常工作并返回上面的错误.

解决方案是设置特定版本 - 在这种情况下

宝石"pg","〜> 0.13.2"

有同样问题的人吗?

postgresql ruby-on-rails pg

6
推荐指数
1
解决办法
3701
查看次数

当数据库位于不同的服务器上时安装postgres gem

我的数据库与应用程序位于不同的服务器上.当我运行"捆绑"时,我收到以下错误:

没有pg_config ...无论如何都要尝试.如果构建失败,请使用--with-pg-config =/path/to/pg_config重试

如果pg未实际安装在应用程序服务器上,如何设置pg配置路径?我也尝试过:

bundle config build.pg --without-pg_config

谢谢

postgresql gem centos ruby-on-rails pg

6
推荐指数
1
解决办法
1135
查看次数

"运行rspec时,无法在任何源中找到pg-0.12.2"

我正在使用Hartl的Rails教程构建twitter克隆应用程序.我克隆了我的git repo(https://github.com/stewartmccoy/rails_tutorial)并将代码放到我以前在我的工作计算机上的个人计算机上.因此,我的开发人员环境可能与我的Gemfile中指定的略有不同.

我的环境:Mac OS 10.6.8 Rails 3.2.13 ruby​​ 1.9.3p392(2013-02-22修订版39386)[x86_64-darwin10.8.0]

*本地宝石*

  • 动作邮件(3.2.13,3.2.11,3.2.1)
  • actionpack(3.2.13,3.2.11,3.2.1)
  • activemodel(3.2.13,3.2.11,3.2.1)
  • activerecord(3.2.13,3.2.11,3.2.1)
  • activeresource(3.2.13,3.2.11,3.2.1)
  • activesupport(3.2.13,3.2.11,3.2.1)
  • 可寻址的(2.3.2)
  • 注释(2.5.0)
  • arel(3.0.2)
  • bcrypt-ruby(3.0.1)
  • bigdecimal(1.1.0)
  • bootstrap-sass(2.1.0.0)
  • bootstrap-will_paginate(0.0.6)
  • 建设者(3.0.4)
  • 捆绑器(1.3.4)
  • 水豚(2.0.2,1.1.2)
  • 子进程(0.3.9,0.3.6)
  • 咖啡轨(3.2.2)
  • 咖啡脚本(2.2.0)
  • coffee-script-source(1.6.2,1.6.1,1.4.0)
  • 黄瓜(1.2.1)
  • 黄瓜栏杆(1.2.1)
  • database_cleaner(0.7.0)
  • 差异(1.2.1,1.1.3)
  • erubis(2.7.0)
  • execjs(1.4.0)
  • factory_girl(4.1.0)
  • factory_girl_rails(4.1.0)
  • faker(1.0.1)
  • ffi(1.4.0,1.3.1)
  • 小黄瓜(2.11.5)
  • 徒步旅行(1.2.1)
  • i18n(0.6.1)
  • io-console(0.3)
  • 旅程(1.0.4)
  • jquery-rails(2.2.1,2.1.4,2.0.2)
  • json(1.7.7,1.7.6,1.7.5,1.5.5)
  • libwebsocket(0.1.7.1)
  • 邮件(2.5.3,2.4.4)
  • 哑剧型(1.21,1.19)
  • minitest(2.5.1)
  • multi_json(1.7.1,1.5.0)
  • nokogiri(1.5.8,1.5.7,1.5.6)
  • 第(0.14.1)页
  • 多语言(0.3.3)
  • 机架(1.4.5,1.4.4,1.4.1)
  • 机架缓存(1.2)
  • rack-ssl(1.3.3,1.3.2)
  • 机架测试(0.6.2)
  • 铁轨(3.2.13,3.2.1)
  • 铁路(3.2.13,3.2.11,3.2.1)
  • 耙子(10.0.3,0.9.2.2)
  • rdoc(3.12.2,3.12,3.9.5)
  • rspec-core(2.13.1)
  • rspec-expectations(2.13.0)
  • rspec-mocks(2.13.0)
  • rspec-rails(2.13.0)
  • rubygems-bundler(1.1.1)
  • rubyzip(0.9.9)
  • rvm(1.11.3.6)
  • sass(3.2.7,3.2.4)
  • sass-rails(3.2.6,3.2.5)
  • selenium-webdriver(2.31.0,2.27.2)
  • 链轮(2.2.2,2.1.3)
  • sqlite3(1.3.7)
  • thor(0.17.0,0.16.0,0.14.6)
  • 倾斜(1.3.6,1.3.3)
  • 树梢(1.4.12) …

postgresql gem ruby-on-rails pg

6
推荐指数
1
解决办法
8903
查看次数

使用Ruby PG Gem的代理

我正在Heroku上开发一个Rails应用程序,需要对我们客户的数据库进行标注.我们已经设置了一个代理,使我们的出站IP地址成为静态,现在正在配置我们的"连接"类以使用该代理.

我的麻烦是ruby的PG gem(https://deveiate.org/code/pg/),我们用它来连接到像dbs这样的PostgreSQL,它没有内置的代理功能.

有没有人知道如何使用Ruby PG gem的代理(或具有代理功能的健康替代gem)?

提前致谢 :-)

ruby-on-rails heroku pg

6
推荐指数
0
解决办法
62
查看次数

首次使用 Node 和 pg 创建数据库后如何创建表

我正在尝试创建一个节点应用程序,它可以通过创建数据库然后创建表和字段来在数据库端自行设置。下面是我用来独立完成每项任务的两个函数。我能否获得有关如何将这些组合在一起的帮助?我应该使用 pg-promise 而不是 pg 吗?

function createDatabase(){

const pool = new pg.Pool({
    user: 'postgres',
    host: '127.0.0.1',
    database: 'postgres',
    password: 'postgres',
    port: '5432'}
);

pool.query("CREATE DATABASE myApp;", 
    (err, res) => {
    console.log(err, res);
    pool.end();

});
}


function createTable(){

const pool = new pg.Pool({
    user: 'postgres',
    host: '127.0.0.1',
    database: 'myApp',
    password: 'postgres',
    port: '5432'}
);

pool.query("CREATE TABLE session(sessionguid UUID NOT NULL, created 
text NOT NULL, sessionlife integer NOT NULL)", 
    (err, res) => {
    console.log(err, res);
    pool.end();
});

}
Run Code Online (Sandbox Code Playgroud)

postgresql node.js pg

6
推荐指数
1
解决办法
1万
查看次数

如何使用 golang 捕获新的 postgreSQL 记录的事件

我有一个连接到数据库并可以从中获取数据的脚本,当任何新记录添加到数据库表中时,我可以以某种方式让它通知我吗

sql postgresql notifications go pg

6
推荐指数
2
解决办法
8668
查看次数

ARM64 架构(M1 芯片):无法安装 pg gem(使用 PostgresApp)

我一直在尝试在运行 Big Sur 的计算机(带有 M1 的 Macbook Pro 2020)上安装一个 rails 项目。

我安装了 PostgresApp。

运行时bundle install它无法构建pggem,所以我尝试手动安装 gem(通过这样做gem install pg- 也尝试使用gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/10/bin/pg_config)。

我收到一条错误消息:

ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Run Code Online (Sandbox Code Playgroud)

检查错误日志时,我看到:

have_library: checking for PQconnectdb() in -lpq... -------------------- no

ld: warning: ignoring file /Applications/Postgres.app/Contents/Versions/13/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 …
Run Code Online (Sandbox Code Playgroud)

rubygems ruby-on-rails pg postgresapp apple-silicon

6
推荐指数
3
解决办法
2857
查看次数