标签: pg

通过 Rails 和 pg gem 插入 PostgreSQL 服务器时,“令牌“-”无效

我最近开始尝试设置一个新的本地 PostgreSQL 服务器,连接到现有的 Rails 应用程序。我有一张要插入的表:

postgres=# \d+ events.t_sales_events
                                                             Table "events.t_sales_events"
   Column   |            Type             |                              Modifiers                              | Storage  | Stats target | Description 
------------+-----------------------------+---------------------------------------------------------------------+----------+--------------+-------------
 id         | integer                     | not null default nextval('events.t_sales_events_id_seq'::regclass) | plain    |              | 
 event_name | character varying(45)       | not null                                                            | extended |              | 
 actor_id   | integer                     |                                                                     | plain    |              | 
 actor_type | character varying(45)       |                                                                     | extended |              | 
 json       | jsonb                       |                                                                     | extended |              | 
 created    | timestamp without time zone | not null …
Run Code Online (Sandbox Code Playgroud)

ruby postgresql ruby-on-rails pg

5
推荐指数
1
解决办法
3224
查看次数

docker 中的 pg_dump 服务器和 pg_dump 版本不匹配

当我psql --versionrailsApp容器内运行命令时,我得到9.4.12,当我在postgres容器内运行相同的命令时,我得到9.6.2. 我怎样才能让版本匹配?

当我尝试在执行pg_dumpsql 导入的Rails App 上进行迁移时,出现以下错误。

pg_dump: server version: 9.6.2; pg_dump version: 9.4.12
pg_dump: aborting because of server version mismatch
rails aborted!
Run Code Online (Sandbox Code Playgroud)

这是我的 Docker-compose.yml 文件:

version: "2.1"
services:
  railsApp:
    build:
      context: ./
    ports:
      - "3000:3000"
    links:
      - postgres
    volumes:
      - .:/app
  postgres:
    image: postgres:9.6
    ports:
      - "5432:5432"
    volumes:
      - ./.postgres:/var/lib/postgresql
Run Code Online (Sandbox Code Playgroud)

Dockerfile:

FROM ruby:2.3.3

# setup /app as our working directory
RUN mkdir /app
WORKDIR /app

# Replace …
Run Code Online (Sandbox Code Playgroud)

postgresql pg-dump pg docker docker-compose

5
推荐指数
1
解决办法
2778
查看次数

postgres 索引包含“块处意外的零页”异常

我在 pg_log 文件中出现了数千次以下错误。如何解决它们。

index "meeting_pkey" contains unexpected zero page at block 410.Please REINDEX it.
index "faultevent_props_pkey" contains unexpected zero page at block 37290.
index "faultevent_pkey" contains unexpected zero page at block 1704
Run Code Online (Sandbox Code Playgroud)

postgresql logging pg psql

5
推荐指数
1
解决办法
9940
查看次数

错误:运行 npm install pg 后找不到模块“pg”

使用 VSCode。为 Windows 安装了最新的 Node.js(首次用户)以及所需的模块,其中一个是“pg”(npm install pg)

在我的脚本的顶部有这样的内容: const pg = require('pg');

当我尝试调试时,当它到达该行时我收到此错误:

Exception has occurred: Error
Error: Cannot find module 'pg'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (c:\EBI\Work\Node-pg-log\get_pg_log.js:3:12)
at Module._compile (module.js:649:14)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
Run Code Online (Sandbox Code Playgroud)

我还需要安装或设置其他东西吗?调试到位。

node.js pg

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

尝试解码 JSON 日期时显示“JSON 写入中的类型无效 (__NSTaggedDate)”

当我尝试从具有日期变量的数据库中解码 JSON 对象时,出现错误“由于未捕获的异常‘NSInvalidArgumentException’而终止应用程序,原因:‘JSON 写入中的无效类型 (__NSTaggedDate)’”。错误发生在以下代码行: let jsonData = try JSONSerialization.data(withJSONObject: self) 中:

extension Array where Element == Dictionary<String,Any> {
    func decode<T>() throws -> [T] where T: Codable {
        let jsonData = try JSONSerialization.data(withJSONObject: self)
        // 1.
        let decoder = JSONDecoder()

        // 2.
        return try decoder.decode([T].self, from: jsonData)
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用此方法使用 PG 依赖项将 Postgres SELECT 查询的结果转换为 Codable 对象数组。

case .success(let result):
   let array = result.rows.map { Dictionary($0) }

   let objects = try! array.decode() as [Model]

   completion(objects,nil)
Run Code Online (Sandbox Code Playgroud)

postgresql json date pg swift

5
推荐指数
0
解决办法
4588
查看次数

错误 — PG::InvalidParameterValue:错误:参数“client_min_messages”的值无效:“panic”

我在使用 Docker 运行 Ruby on Rails 项目时遇到问题。我有预感这与运行 macOS Catalina (10.15.1) 有关。当我尝试这样做时,问题就出现了docker-compose run web rake db:create

当我运行时,docker-compose run web rake db:create我得到以下输出:

Starting vft_db_1 ... done
PG::InvalidParameterValue: ERROR:  invalid value for parameter "client_min_messages": "panic"
HINT:  Available values: debug5, debug4, debug3, debug2, debug1, log, notice, warning, error.
: SET client_min_messages TO 'panic'
/usr/local/bundle/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec'
/usr/local/bundle/gems/activerecord-
...
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"db", "username"=>"postgres", "password"=>nil, "pool"=>5, "database"=>"vft_test", "client_min_messages"=>"warning"}
Run Code Online (Sandbox Code Playgroud)

这是我的database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  host: db
  username: …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails pg macos-catalina

5
推荐指数
1
解决办法
2051
查看次数

prisma $queryRaw 不适用于字符串中的单引号

我有一个查询

select count(id), status,  "createdAt"::date from "ProjectLog" where "projectId" = (select id from "Project" where slug = ${id}) and "createdAt" > current_date - interval '${interval} day' group by "createdAt"::date, status;
Run Code Online (Sandbox Code Playgroud)

我还尝试过用户Prisma.sql在引号内传递值,但它不断抛出错误,它期望 1 个参数,但 fount 2。

我的 prisma 没有这个问题,2.20.1 这个问题只发生在版本上3.3.0

Query: select count(id) as count, status,  "createdAt"::date from "ProjectLog" where "projectId" = (select id from "Project" where slug = $1) and "createdAt" >  current_date - interval '$2 day' and key notnull group by "createdAt"::date, status
Param: ["main","30"] …
Run Code Online (Sandbox Code Playgroud)

postgresql orm pg prisma

5
推荐指数
1
解决办法
4111
查看次数

MAC M1 ARM Core - Ruby 和 Gem pg 安装问题

只是想发布一个问题,我gem install pg -v '0.21.0'在 M1 Mac 系统中安装 2 个项目时遇到问题,有人遇到过这样的问题吗

这是我收到的错误

checking for pg_config_manual.h... yes 
checking for PQconnectdb() in -lpq... no 
checking for PQconnectdb() in -llibpq... no 
checking for PQconnectdb() in -lms/libpq... no 
Can't find the PostgreSQL client library (libpq)
> *** extconf.rb failed ***
Run Code Online (Sandbox Code Playgroud)

Postgres 是通过 Homebrew 安装的,并且还安装了 libpq,我尝试在安装 gem pg 时指向 libpq 并尝试解决问题,但这也不起作用,附加 mkmf 日志以获取有关错误的更多详细信息,仅供参考 Postgres 是安装后,我还可以通过终端和其他软件连接到它。我从堆栈中尝试了很多答案都无济于事我对 Ruby 和 MAC 很陌生,任何帮助都会很棒

更多信息,但不确定安装 ruby​​ 版本 2.5.0 和 2.3.6 时是否存在相关问题,但现已修复(之前显示为已损坏,因此将其清除并在手动将 openssl@1.0 手动配置到 MAC 后再次安装),但当它被损坏时pg 和捆绑安装对于我的一个项目都运行良好,但 Ruby 2.3.6 版本安装失败 …

ruby macos homebrew rubygems pg

5
推荐指数
0
解决办法
755
查看次数

NodeJs postgresql 连接失败

  • 我尝试从 nodeJs 连接到 rds postgresql版本 12,如下所述。它工作完全正常,没有任何问题。

    const config = {
    
        user: process.env.PG_DB_USERNAME,
        password: process.env.PG_DB_PASSWORD,
        database: process.env.PG_DB_NAME,
        host: process.env.PG_DB_HOST,
        port: process.env.PG_DB_PORT,
     }
       const pool = new Pool(config)
    
    Run Code Online (Sandbox Code Playgroud)

当我们使用 postgresql 15.2 版 从节点 Js 连接时,我们最终遇到了以下错误。

错误

{"length":181,"name":"error","severity":"FATAL","code":"28000","file":"auth.c","line":"543","routine":"ClientAuthentication","level":"error","timestamp":"2023-06-19T14:13:33.294Z"}

[ERROR] error: no pg_hba.conf entry for host "XXXXX", user "test", database "testdb", no encryption

at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/usr/src/app/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:526:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead …
Run Code Online (Sandbox Code Playgroud)

postgresql amazon-rds node.js pg

5
推荐指数
1
解决办法
2434
查看次数

在Ubuntu 12.04上安装gem pg版本0.12.2时出错

即时通讯在Ubuntu 12.04上运行,我正在尝试在Ruby 1.9.3p194/Rails 3.2.3上安装pg gem v'0.12.2'.我已经安装了libpq-dev和build-essential但我仍然得到同样的错误:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /var/lib/gems/1.9.1 directory.
fernando@ubuntu:/media/fernando/OS/Rails/oops_booking$ sudo gem install pg -v '0.12.2'
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails pg ubuntu-12.04

4
推荐指数
1
解决办法
2642
查看次数