我更新了包含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
谢谢
我正在尝试创建一个节点应用程序,它可以通过创建数据库然后创建表和字段来在数据库端自行设置。下面是我用来独立完成每项任务的两个函数。我能否获得有关如何将这些组合在一起的帮助?我应该使用 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) 我想为Heroku构建一个Rails 3应用程序.他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres 9.0.现在我需要一个postgres gem,并且一致认为,出于性能原因,你需要pg gem.但是当我尝试通过rvm下的gem install安装pg时,我完全感到困惑.
我已经非常明确地指定了所有postgres目录的位置,但仍然无法完成安装:
$ env ARCHFLAGS='-arch x86_64' gem install pg -- \
--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/postgresql.conf \
--with-pg-include=/opt/local/include/postgresql90/ \
--with-pg-lib=/opt/local/lib/postgresql90/
Using config values from /opt/local/var/db/postgresql90/defaultdb/postgresql.conf
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/guy/.rvm/ruby-1.9.2-p136/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include=${pg-dir}/include
--with-pg-lib=${pg-dir}/lib
--with-pg-config
extconf.rb:24:in ``': …Run Code Online (Sandbox Code Playgroud) 我使用此命令备份200GB数据库(postgres 9.1,win7 x64):
pg_dump -Z 1 db_name > backup
它创建了16GB的文件,我觉得很好,因为以前的备份工作(并且由ext工具打包)具有相似的大小.现在,当我尝试使用时恢复到PG9.2时pg_restore,我收到错误:
input file does not appear to be a valid archive
用pg_restore -Ft:
[tar archiver] corrupt tar header found in ? (expected 13500752, com puted 78268) file position 512
Gzip也表明它已经损坏了.当我在Total Commander中打开备份文件时,内部文件只有1.8GB.当我在寻找解决方案时,-Cf可能需要使用参数进行转储.
现在哪种格式的文件?它只是tar或gzip(winrar显示gzip)?有没有办法正确地恢复它或者它以某种方式被破坏(转储时没有错误)?可能是由于tar或gzip的文件大小限制?
这是一个非常奇怪的.我试图做一个简单的rake db:test:clone或创建,无论我做什么,从清除gemset到尝试各种database.yml配置,我得到最奇怪的错误:
LINE 1: CREATE DATABASE "tdt_test"0.0
Run Code Online (Sandbox Code Playgroud)
有没有人见过这样的事情呢?WTF是"0.0!?" 我正在运行Rails 3.2,RSpec和pg gem 0.14.1
04:15 PM ~/projects/dmvcs (feature/helpdesk) => RAILS_ENV=test rake db:create
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead.
Notice: for 10x faster LSI support, please install http://rb-gsl.rubyforge.org/
PG::Error: ERROR: syntax error at or near "0.0"
LINE 1: CREATE DATABASE "tdt_test"0.0
^
: CREATE DATABASE "tdt_test"0.0
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `async_exec'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `block in execute'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:653:in `execute'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in …Run Code Online (Sandbox Code Playgroud) unit-testing rspec-rails pg ruby-on-rails-3 rails-postgresql
Heyo.如果在另一个帖子中回答了这个问题,我会提前道歉.我搜索了网站,但没有找到答案.但是,最接近的相关问题是启动server-libq.5.dylib时Ruby on Rails/PostgreSQL - Library not Loaded错误,但它从未得到解决,答案对我没有帮助.
我正在尝试在我的Mac OSX 10.6.8上运行PostgreSQL.我已经安装了Ruby 1.9.3p392和Rails 3.2.13.
由于我的10.6.8和PostGresApp需要10.7+,我尝试使用此处提供的手动安装程序(v9.2.3)安装PG:http://www.enterprisedb.com/products-services-training/pgdownload
我首先将它安装到默认路径:/Library/PostgreSQL/9.2/.然后我安装了pg gem(PATH=$PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg).当我尝试rails s启动localhost时,我收到了以下错误.
经过一些阅读,我猜测它可能是一个路径错误,所以我删除了pg gem,然后使用了postgresql卸载程序.然后我重新安装了/users/stewartmccoy/Library/PostgreSQL/9.2/...中的pg,然后重新安装了pg gem.但我仍然得到同样的错误.
有关如何正确安装PostgreSQL并让我的rails服务器运行的任何想法?
stewart-mccoys-macbook:footy_subs stewartmccoy$ rails s
/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `require': dlopen(/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError)
Referenced from: /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle
Reason: image not found - /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
from …Run Code Online (Sandbox Code Playgroud) 使用此查询时(与Railscasts第273集中相同):
@locations = Location.near(params[:search], 50, :order => :distance)
Run Code Online (Sandbox Code Playgroud)
或者,更简洁:
@mymodels = MyModel.near(address, distance, order: :distance)
Run Code Online (Sandbox Code Playgroud)
我收到错误:
PG::UndefinedColumn: ERROR: column mymodels.distance does not exist
Run Code Online (Sandbox Code Playgroud)
该distance列应该由Geocoder gem添加到结果中,但它似乎没有出现在结果中(所以我得到了上面的错误).
pg ×10
postgresql ×7
gem ×2
backup ×1
centos ×1
go ×1
libpq ×1
macos ×1
node.js ×1
pg-dump ×1
postgresapp ×1
restore ×1
rspec-rails ×1
ruby ×1
rubygems ×1
rvm ×1
sql ×1
unit-testing ×1