Tag: postgresql 9.1

Heroku上的Rails应用程序无法写入PostgreSQL数据库,只能读取

我有一个Ruby on Rails应用程序,可以在本地使用sqlite3数据库,并且可以毫无问题地保存和检索记录。 当使用postgresql数据库在http://moviedata.herokuapp.com/上部署到Heroku时,记录不会保存,即使它看起来像日志说的那样。 从db精细读取的记录和数据按预期显示。 添加记录的尾标记日志是: 2012-08-21T19:51:31+00:00 app[web.1]: 2012-08-21T19:51:31+00:00 app[web.1]: 2012-08-21T19:51:31+00:00 app[web.1]: Started POST “/” for 50.53.6.156 at 2012-08-21 19:51:31 +0000 2012-08-21T19:51:31+00:00 app[web.1]: Parameters: {“utf8″=>”✓”, “authenticity_token”=>”+BYQLzhrfDkUVW8UaHikHpmtGHxpeQ/yF4VByHh9m1I=”, “movie”=>{“title”=>”The Running Man”, “description”=>”A documentary about a public execution game show.”, “year”=>”1987”, “genre”=>”science fiction”}, “commit”=>”Create Movie”} 2012-08-21T19:51:31+00:00 app[web.1]: Processing by MoviesController#index as HTML 2012-08-21T19:51:31+00:00 app[web.1]: Rendered movies/index.html.erb within layouts/application […]

postgres hstore存在且不存在同时

我在远程服务器上设置了Rails应用程序并创建了一个hstore扩展 sudo -u postgres psql CREATE EXTENSION hstore; 然后,我在其中一个postgres表中部署了一个使用hstore的应用程序的迭代,但是当它运行迁移时,它给出了一条错误消息 PG::UndefinedObject: ERROR: type “hstore” does not exist 然后我再次尝试这样做 sudo -u postgres psql CREATE EXTENSION hstore; 但它告诉我hstore已经存在 ERROR: extension “hstore” already exists 这圈继续。 知道可能导致这个问题的原因是什么? 我在Ubuntu 12.04服务器上使用postgres 9.1 更新注意,想知道这个问题是否与权限有关,我试图检查我的权限,但是得到了以下错误 sudo -u postgres psql -U username psql: FATAL: Peer authentication failed for user “username” 更新虽然安装了hstore,但它不是我正在使用的数据库的扩展。 如何在特定的数据库中安装它? psql -d db_production […]

返回没有特定键的记录 – Rails4 HStore Postgresql查询

我有一个模型任务 t.string “name” t.hstore “actions” 例: #”9″}, #”1″}, #<Task id: 3, name: "third", actions: nil, #”11″}, 我需要找到行动的所有记录:nil,:今天<10和关键:今天不存在。 这是1,2,3任务。 Task.where(“actions -> ‘today’ ‘today’ < '10' OR actions IS NULL") – it return 1 and 3 records. 我怎么能找到所有没有钥匙的记录:今天在行动?

在多服务器环境中,如果站点的不活动超过15分钟,则服务器将失去与PostgreSQL数据库的连接

如果我的暂存(2台服务器)或生产(4台服务器)服务器在大约15分钟内没有活动,我在airbrake中会出现以下错误。 以下是错误消息: ActiveRecord :: StatementInvalid:PG ::错误:无法从服务器接收数据:连接超时 要么 PG ::错误:无法连接到服务器:连接超时服务器是否在主机“tci-db4.dev.prod”上运行并接受端口5432上的TCP / IP连接? 我正在使用PostgreSQL作为我的数据库。 其中一个服务器也充当数据库服务器。 环境: Ruby 1.9.3 (这也发生在Ruby 1.8.7下,但是自升级以来更糟,因为服务器上的ruby进程将达到100%并保持100%直到服务器丢失数据库连接时被杀死。 Rails 3.1.6 PG GEM 0.13.2 Postgres 9.1 Phusion Passenger 这个问题已经发生了一年多,所以我希望有人对如何解决这个问题有一些了解。 谢谢。

具有正确的Rails命名和约定的“PG :: UndefinedTable:ERROR:relation不存在”

我已经阅读了很多像这样的底池,但我见过的所有解决方案都在模型,命名和Rails惯例的命名中。 现在,当我在PostgreSQL 9.1中的生产环境中第一次运行时, 我遇到了这个问题 rake db:migrate RAILS_ENV=production 要么 rake db:schema:load RAILS_ENV=production 我可以毫无问题地创建数据库: rake db:create RAILS_ENV=production => OK 错误是 rake aborted! PG::UndefinedTable: ERROR: relation “categories” does not exist LINE 5: WHERE a.attrelid = ‘”categories”‘::regclass ^ : SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid […]

Rails:rake db:create:all无法连接到PostgreSQL数据库

我正在尝试创建一个使用PostgreSQL的Rails应用程序。 这是对我所做的描述。 PostgreSQL设置: 我通过由Martin Pitt维护的ppa:pitti / postgresql安装了PostgreSQL 9.1.3。 之前安装了PostgreSQL 8.4; 我不确定它是否仍然安装或消失。 我添加了一个数据库用户,该用户具有与我的Ubuntu帐户同名的数据库的超级用户权限。 我用sudo service postgresql start数据库守护进程。 我通过由Gerfried Fuchs维护的ppa:rhonda / pgadmin3安装了pgadmin3,版本1.14.0 Beta 1 。 我可以使用我的用户帐户和密码以及端口5433通过pgadmin3连接。 我在pg_hba.conf中的 postgres配置如下(为了便于阅读,删除了注释)。 […] local all postgres peer local all all peer host all all 127.0.0.1/32 md5 host all all ::1/128 md5 Rails设置: 现在我想创建一个使用PostgreSQL的Rails应用程序。 我通过RVM安装了Ruby 1.9.3-p125。 我将Rails 3.2.3安装到Gemset ruby​​-1.9.3-p125@global中。 我为应用程序创建了一个.rvmrc和Gemset。 我通过rails new […]

连接被拒绝(PGError)(postgresql和rails)

当我尝试使用“$ rails s”运行我的localhost时,我一直收到此错误: (Mac OSX 10.8.3)(ruby 2.0.0p195(2013-05-14修订版40734)[x86_64-darwin12.3.0])(Rails 3.2.11)(psql(PostgreSQL)9.2.2)**用自制软件安装 我一直在做很多卸载postgresql并重新安装,所以我有预感,某些地方可能存在冲突的库……我只是不知道从哪里开始。 我在同一个文件夹中安装了Postgresql 9.1和9.2,只是将9.1移到垃圾箱中。 这是我在终端中运行“rails s”时的输出 Danny$ rails s ^[b=> Booting Thin => Rails 3.2.11 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize’: could not connect to server: Connection refused (PGError) Is the server running on […]

没有运算符匹配给定的名称和参数类型

我设置我的Rails 3.2.x应用程序以使用PostgreSQL HStore但我收到了一个错误。 看起来环境没有拾取hstore扩展。 我已经重新启动了我的机器,检查了数据库扩展等。 当我尝试执行时: User.where(“settings @> (:key => :value)”, :key => “setting_x”, :value => “test”) 我收到一个错误:( @>无法识别,即没有安装扩展名hstore ?) HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 我的Rails应用程序设置是: Gemfile.rb: gem ‘activerecord-postgres-hstore’ 移民: add_column :users, :settings, :hstore execute “CREATE INDEX CONCURRENTLY users_gin_settings ON users USING […]

准备好的陈述已经存在

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