postgresql

Postgres replication

本秂侑毒 提交于 2021-02-08 18:35:00
问题 Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as a data storage to RoR/Python LAMP-like application. What kind tools are there that are simple and robust enough for replication of the main database to a second machine? I looked through some packages (Slony-I and etc.) but it would be great to hear real-life stories as well. Right now I'm not concerned with load balancing and etc. I am thinking about using simple Write-Ahead-Log strategy for now. 回答1: If you are not

Change IdentityServer4 Entity Framework table names

孤人 提交于 2021-02-08 18:32:32
问题 I am trying to change the default table names created by the PersistedGrantDb and ConfigurationDb for IdentityServer4 and have Entity Framework generate the correct SQL. For example; instead of the using the entity IdentityServer4.EntityFramework.Entities.ApiResource using the table ApiResources , I want the data to be mapped into a table named mytesttable According to the documentation this should be as simple as adding ToTable invocations for each entity that I want to remap in the

Postgres replication

假装没事ソ 提交于 2021-02-08 18:30:52
问题 Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as a data storage to RoR/Python LAMP-like application. What kind tools are there that are simple and robust enough for replication of the main database to a second machine? I looked through some packages (Slony-I and etc.) but it would be great to hear real-life stories as well. Right now I'm not concerned with load balancing and etc. I am thinking about using simple Write-Ahead-Log strategy for now. 回答1: If you are not

how to pass variable to copy command in Postgresql

心不动则不痛 提交于 2021-02-08 15:16:38
问题 I tried to make a variable in SQL statement in Postgresql, but it did not work. There are many csv files stored under the path. I want to set path in Postgresql that can tell copy command where can find csv files. SQL statement sample: \set outpath '/home/clients/ats-dev/' \COPY licenses (_id, name,number_seats ) FROM :outpath + 'licenses.csv' CSV HEADER DELIMITER ','; \COPY uploaded_files (_id, added_date ) FROM :outpath + 'files.csv' CSV HEADER DELIMITER ','; It did not work. I got error:

How to store java.util.ArrayList in Postgresql using Spring

空扰寡人 提交于 2021-02-08 13:47:17
问题 I am trying to do a batch-insert of a collection of beans. One of the properties of the bean is an ArrayList. The batch update fails with the exception: Can't infer the SQL type to use for an instance of java.util.ArrayList. Use setObject() with an explicit Types value to specify the type to use. I don't know which Postgresql data type to use for the ArrayList to be compatible. Is there a way I can do the batch update of the beans without changing the data type of its properties? The Bean:

postgresql jsonb case insensitive query

倖福魔咒の 提交于 2021-02-08 13:45:24
问题 I have a table like: CREATE TABLE cityData ( item character varying, data jsonb ); it contains values like ITEM DATA test1 [{"rank":"1", "city":"New York"},{"rank":"3", "city":"Sidney"}] test2 [{"rank":"2", "city":"NEW YORK"},{"rank":"4", "city":"New Delhi"}] I need to get number of distinct json objects where city is 'New York' I am using the following query SELECT * FROM cityData t WHERE ( data @> '[{"city":"New York"}]') and t.item ilike '%test%'; But this query outputs test1 row. I need

How to store DateTimeOffset in PostreSQL

☆樱花仙子☆ 提交于 2021-02-08 13:43:47
问题 I am having a problem with retrieving a DateTimeOffset from a PostgreSQL database using Entity Framework. As far as researching the problem, I found this article that helps me understand what the problem is, but I can't figure out how to fix it. I have an API that allows users to upload files (mostly images) and it extracts the date that the image was taken and stores it in the database. It works great most of the time. However, if the date is between March 11 to sometime in April (date

PostgreSQL UPDATE substring replacement

99封情书 提交于 2021-02-08 12:21:20
问题 I have a few rows in a test database where there are dollar signs prefixed to the value. I want to UPDATE the values in the name row of the test1 table however when I threw the following query together it emptied the six rows of data in the name column... UPDATE test1 SET name=overlay('$' placing '' from 1 for 1); So "$user" became "" when I intended for that column/row value to become "user". How do I combine UPDATE and a substr replacement without deleting any of the other data? If there

PostgreSQL UPDATE substring replacement

China☆狼群 提交于 2021-02-08 12:21:17
问题 I have a few rows in a test database where there are dollar signs prefixed to the value. I want to UPDATE the values in the name row of the test1 table however when I threw the following query together it emptied the six rows of data in the name column... UPDATE test1 SET name=overlay('$' placing '' from 1 for 1); So "$user" became "" when I intended for that column/row value to become "user". How do I combine UPDATE and a substr replacement without deleting any of the other data? If there

Having issues combining HAVING with WHERE on a very simple QUERY

微笑、不失礼 提交于 2021-02-08 12:01:20
问题 This is what I have tried so far: SELECT group_id, player_id as winner_id /* ,sum(M1.first_score + M2.second_score), sum(M2.first_score + M1.second_score) */ FROM players as P1 LEFT JOIN matches as M1 ON M1.first_player = P1.player_id LEFT JOIN matches as M2 ON M2.second_player = P1.player_id LEFT JOIN matches as M3 ON M3.first_player = P1.player_id LEFT JOIN matches as M4 ON M4.second_player = P1.player_id --WHERE P1.player_id is not null /*or P2.player_id is not null*/ GROUP BY group_id, P1