我正在尝试使用 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,但也没有成功。
我使用 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 …
我正在尝试将数据从我的生产数据库传输到我的暂存数据库但没有成功.
我正在关注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)
但我收到相同的消息,没有实际转移. …
我更新了包含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"
有同样问题的人吗?
我的数据库与应用程序位于不同的服务器上.当我运行"捆绑"时,我收到以下错误:
没有pg_config ...无论如何都要尝试.如果构建失败,请使用--with-pg-config =/path/to/pg_config重试
如果pg未实际安装在应用程序服务器上,如何设置pg配置路径?我也尝试过:
bundle config build.pg --without-pg_config
谢谢
我正在使用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]
*本地宝石*
我正在Heroku上开发一个Rails应用程序,需要对我们客户的数据库进行标注.我们已经设置了一个代理,使我们的出站IP地址成为静态,现在正在配置我们的"连接"类以使用该代理.
我的麻烦是ruby的PG gem(https://deveiate.org/code/pg/),我们用它来连接到像dbs这样的PostgreSQL,它没有内置的代理功能.
有没有人知道如何使用Ruby PG gem的代理(或具有代理功能的健康替代gem)?
提前致谢 :-)
我正在尝试创建一个节点应用程序,它可以通过创建数据库然后创建表和字段来在数据库端自行设置。下面是我用来独立完成每项任务的两个函数。我能否获得有关如何将这些组合在一起的帮助?我应该使用 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) 我有一个连接到数据库并可以从中获取数据的脚本,当任何新记录添加到数据库表中时,我可以以某种方式让它通知我吗
我一直在尝试在运行 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) pg ×10
postgresql ×7
gem ×2
heroku ×2
node.js ×2
centos ×1
database ×1
go ×1
javascript ×1
pg-dump ×1
pg-promise ×1
pg-restore ×1
postgresapp ×1
ruby ×1
rubygems ×1
sql ×1