postgresql

Multiple Databases With Rails Not Working For Remote Database

我的梦境 提交于 2021-01-27 11:01:28
问题 I have a remote read-only postgres database that is maintained from a docker instance of cardano-db-sync. I managed to connect the development database to it, it was working fine. But since it is read-only I wanted to add another database for User and other modifiable tables. this is the set up I prepared: # config/database.yml default: &default adapter: postgresql encoding: unicode pool: 5 development: <<: *default primary: database: 'db_sync' cexplorer: database: 'cexplorer' username: <%=

Finding the spanning forest (WITH RECURSIVE, PostgreSQL 9.5)

半腔热情 提交于 2021-01-27 10:46:51
问题 I have a table of identities (i.e. aliases) for an arbitrary number of people. Each row has a previous name and a new name. In production, there are about 1 M rows. For example: id, old, new --- 1, 'Albert', 'Bob' 2, 'Bob', 'Charles' 3, 'Mary', 'Nancy' 4, 'Charles', 'Albert' 5, 'Lydia', 'Nancy' 6, 'Zoe', 'Zoe' What I want is to generate the list of users and reference all of their respective identities. This is analogous to finding all of the nodes in each graph of connected identities, or

Finding the spanning forest (WITH RECURSIVE, PostgreSQL 9.5)

大兔子大兔子 提交于 2021-01-27 10:43:23
问题 I have a table of identities (i.e. aliases) for an arbitrary number of people. Each row has a previous name and a new name. In production, there are about 1 M rows. For example: id, old, new --- 1, 'Albert', 'Bob' 2, 'Bob', 'Charles' 3, 'Mary', 'Nancy' 4, 'Charles', 'Albert' 5, 'Lydia', 'Nancy' 6, 'Zoe', 'Zoe' What I want is to generate the list of users and reference all of their respective identities. This is analogous to finding all of the nodes in each graph of connected identities, or

Searching encrypted field in Postgres

女生的网名这么多〃 提交于 2021-01-27 09:38:09
问题 I'm attempting to query an encrypted field in postgres using "pgp_sym_encrypt". I'm running my test by setting all the first names in my table to an encrypted value: update person set first_name = pgp_sym_encrypt('test', 'password'); Then selecting on it: select * from person where first_name = pgp_sym_encrypt('test', 'password'); This returns no results. If I change it to use the normal postgres encryption it will return all the rows in the table: update person set first_name = encrypt('test

Searching encrypted field in Postgres

为君一笑 提交于 2021-01-27 09:37:30
问题 I'm attempting to query an encrypted field in postgres using "pgp_sym_encrypt". I'm running my test by setting all the first names in my table to an encrypted value: update person set first_name = pgp_sym_encrypt('test', 'password'); Then selecting on it: select * from person where first_name = pgp_sym_encrypt('test', 'password'); This returns no results. If I change it to use the normal postgres encryption it will return all the rows in the table: update person set first_name = encrypt('test

PostgreSql “running post install step…the Database Cluster Initialisation failed”

烂漫一生 提交于 2021-01-27 07:51:22
问题 I'm a Windows user - it took me a couple of hours of constant installs and uninstalls before I could get this working, with the first 10 or so times coming to see the error message in the title. I place this here as a self-answered question to prevent others who might run into the same problem while installing, and include some basic usage methods for those like me who are first comers in using PostgreSql. 回答1: You have to mannualy run initdb which is present : "C:\Software\PostgreSql\12\bin"

PostgreSql “running post install step…the Database Cluster Initialisation failed”

风格不统一 提交于 2021-01-27 07:49:32
问题 I'm a Windows user - it took me a couple of hours of constant installs and uninstalls before I could get this working, with the first 10 or so times coming to see the error message in the title. I place this here as a self-answered question to prevent others who might run into the same problem while installing, and include some basic usage methods for those like me who are first comers in using PostgreSql. 回答1: You have to mannualy run initdb which is present : "C:\Software\PostgreSql\12\bin"

How to install PLV8 on Windows?

帅比萌擦擦* 提交于 2021-01-27 07:07:08
问题 I'm trying to install this on my PostgreSQL server http://code.google.com/p/plv8js/wiki/PLV8 the docs looks great but the problem is they are for linux and my company only have access to a Windows Server. Someone can tell me how to install PLV8 on Windows please? 回答1: The kind folks at Postgres Online Journal have pre-compiled the binaries for PLV8 for Windows 9.6: http://www.postgresonline.com/journal/archives/367-PLV8-binaries-for-PostgreSQL-9.6-windows-both-32-bit-and-64-bit.html 9.5: http

Postgres: “AT TIME ZONE 'localtime'”== “AT TIME ZONE 'utc'”?

自闭症网瘾萝莉.ら 提交于 2021-01-27 06:57:49
问题 I'm struggling to understand how "AT TIME ZONE 'localtime'" exactly work? By playing with it, I found out that it acts exactly as "AT TIME ZONE 'UTC'" ... But why? Is "localtime" a synonym of "UTC" in postgres? Or it comes from some setting (environment? connection timezone? although checked both, seems they are not related)... There's "localtime" function but I think it is not involved here. Sample SQLs: # date Thu Dec 8 12:00:05 AEDT 2016 # SELECT LOCALTIMESTAMP; ---------------------------

Join against the output of an array unnest without creating a temp table

余生长醉 提交于 2021-01-27 06:38:27
问题 I have a query in a UDF (shown below) which unnest() s an array of integers and joins against it, I have created a local temp table in my pgplsql UDF since I know this works. Is it possible to use unnest directly in a query to perform a join instead of having to create a temp table ? CREATE OR REPLACE FUNCTION search_posts( forum_id_ INTEGER, query_ CHARACTER VARYING, offset_ INTEGER DEFAULT NULL, limit_ INTEGER DEFAULT NULL, from_date_ TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL, to_date_