Tag: pg

无法使用gem“pg”从我的Ruby脚本连接到Postgres(pg)数据库(这不是rails,只是纯粹的ruby)

我为我的Mac OSX机器下载了postgres.app。 我有一个rails应用程序已连接并使用postgres应用程序附带的postgres数据库。 现在我正在编写一个纯Ruby测试脚本(Not Rails,纯Ruby,甚至不是Active Record)来尝试连接到postgres数据库实例。 这些是我设置它的步骤 1) ran this command on the terminal: gem install pg — –with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config 2) Added this code to the test script: #!/usr/bin/env ruby #encoding: utf-8 require “pg” @conn = PG.connect( :dbname => ‘oData’, :user => ‘am’, :password => ”) @conn.exec(“CREATE TABLE programs (id serial NOT NULL, name character varying(255);”); […]

rails pg db for Devise Users的undefined方法`database_authenticatable’

undefined method database_authenticatable’ for # 迁移是: class DeviseCreateUsers false t.recoverable t.rememberable t.trackable t.timestamps end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true end def self.down drop_table :users end end

无法使用Ruby连接到Heroku上的PostgreSQL数据库 – 无法翻译主机名

我正在使用Ruby(而不是Rails)并连接PostgreSQL数据库。 我一直试图在Heroku上设置,但是我在启动应用程序时遇到了问题。 在本地运行应用程序运行正常。 我的本地.env看起来像: postgres://DATABASE_URL=localhost 并且连接到数据库的Ruby连接如下所示: @@db = PGconn.open(:hostaddr => ENV[‘DATABASE_URL’], :dbname => ‘(dbname)’, :password => ‘(password)’) 当我推送到Heroku时,应用程序在该行崩溃,并将此错误写入日志: could not translate host name “postgres://(my heroku db address)” to address: Name or service not known (PG::Error) 那里的数据库地址与我的heroku:config中的DATABASE_URL相匹配。 我正在使用共享数据库。 我尝试使用:host => ENV[‘DATABASE_URL’] (而不是:hostaddr ),但结果相同。 我猜我有一些简单的东西,但是我没有任何好的想法。

使用postgres.app在rvm下需要pg的错误

我在OS X上使用Postgres.app (10.8.3)。 我修改了我的PATH以便应用程序的bin文件夹优先于所有其他文件夹。 Rammy:~ phrogz$ which pg_config /Applications/Postgres.app/Contents/MacOS/bin/pg_config 我安装了rvm并且可以安装pg gem而不会出错,但是当我要求它时,我收到一个错误: Rammy:~ phrogz$ gem -v 1.8.25 Rammy:~ phrogz$ gem install pg Fetching: pg-0.15.1.gem (100%) Building native extensions. This could take a while… Successfully installed pg-0.15.1 1 gem installed Rammy:~ phrogz$ ruby -v -e “require ‘pg'” ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0] /Users/phrogz/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: dlopen(/Users/phrogz/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.1/lib/pg_ext.bundle, 9): […]

准备好的陈述已经存在

我正在尝试使用pg gem中的ruby中的预处理语句。 这就是我的陈述的样子 conn.prepare(“insert_values”, “insert into ” + objectName + “(” + headerStr + “) values (” + prep_values + “)”) conn.exec_prepared(“insert_values”, arr) 我一直在收到错误 准备好的语句insert_values已经存在。 我该如何解决?? 谢谢

升级后的pg_config,ruby pg,postgresql 9.0问题,centos 5

在postgresql 8.1升级到9.0之后,我发现了库依赖的问题。 Postgresql工作正常(连接,查询)。 yum list postgresql* Installed Packages postgresql.i386 9.0.0-1PGDG.el5 installed postgresql-debuginfo.i386 9.0.0-1PGDG.el5 installed postgresql-devel.i386 9.0.0-1PGDG.el5 installed postgresql-libs.i386 9.0.0-1PGDG.el5 installed postgresql-odbcng.i386 0.90.101-2.el5 installed postgresql-plruby.i386 0.5.1-5.el5 installed postgresql-server.i386 9.0.0-1PGDG.el5 install 但当我试图为ruby安装’pg’时,我收到了 gem install pg Building native extensions. This could take a while… ERROR: Error installing pg: ERROR: Failed to build gem native extension. /usr/local/bin/ruby extconf.rb checking […]

在osx上安装pg gem时出错

我在osx 10.6.7尝试在新的rails 3.0.7应用程序上运行bundle install,并且在尝试构建pg gem时它仍然失败。 它一直告诉我,我需要开发人员工具。 但据我所知,我已经安装了开发人员工具。 这是xcodebuild -version的输出 Xcode 3.2.6 Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0 BuildVersion: 10M2518 这是失败的pg gem构建的输出 /Users/bm/.rvm/rubies/ruby-1.9.2-head/bin/ruby extconf.rb –with-pg-config=/Library/PostgreSQL/8.4/bin/pg_config Using config values from /Library/PostgreSQL/8.4/bin/pg_config checking for libpq-fe.h… *** 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 […]

安装pg -v 0.17.1

我正在使用/我想使用Postgresql作为数据库,但是当我输入“bundle install”或“bundle update”时,我收到此错误,我该怎么做才能解决这个问题? 🙂 Installing pg (0.17.1) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb checking for pg_config… no No pg_config… trying anyway. If building fails, please try again with –with-pg-config=/path/to/pg_config checking for libpq-fe.h… no Can’t find the ‘libpq-fe.h header *** extconf.rb failed *** Could not create Makefile due to […]

试图为ror app设置postgres,收到错误 – fe_sendauth:没有提供密码

获得: An error has occurred: Error connecting to the server: fe_sendauth: no password supplied database.yml中的设置与其他计算机上的应用程序设置相同。 如何设置以便我不需要硬编码的密码? 我可以使用PgAdmin-III查看db ok。 我宁愿没有database.yml的密码,因为使用这个应用程序的其他机器没有/需要它,所以它似乎可能与我的Pg安装有关。