postgresql

PostgreSQL: Checking for NEW and OLD in a function for a trigger

狂风中的少年 提交于 2021-02-08 03:54:13
问题 I want to create a trigger which counts rows and updates a field in an other table. My current solution works for INSERT statements but failes when I DELETE a row. My current function: CREATE OR REPLACE FUNCTION update_table_count() RETURNS trigger AS $$ DECLARE updatecount INT; BEGIN Select count(*) into updatecount From source_table Where id = new.id; Update dest_table set count=updatecount Where id = new.id; RETURN NEW; END; $$ LANGUAGE 'plpgsql'; The trigger is a pretty basic one, looking

Postgres COPY command with literal delimiter

橙三吉。 提交于 2021-02-08 03:41:25
问题 I was trying to import a CSV file into a PostgreSQL table using the COPY command. The delimiter of the CSV file is comma (,). However, there's also a text field with a comma in the value. For example: COPY schema.table from '/folder/foo.csv' delimiter ',' CSV header Here's the content of the foo.csv file: Name,Description,Age John,Male\,Tall,30 How to distinguish between the literal comma and the delimiter? Thanks for your help. 回答1: To have the \ to be recognized as a escape character it is

how to avoid column in 'where' clause if parameter is 'NOT PASSED' postgresql

穿精又带淫゛_ 提交于 2021-02-08 03:32:08
问题 Running Query : select * from employee where name = $1 and age = $2 and salary = $3; Problem Query : select * from employee where name = $1 and age = $2; How can I write A Logic That /* If $3 is PASSED Then ( and salary = $3 ) */ Note : /* I Cannot check For null or Empty as $3 as not passed then $3 won't be available for check* / In Node I Am using Like This postGresAdaptor.executeQueryWithParameters(QUERY, QUERYPARAMS, function(error, result) { if (error) { callback(error); } else { data =

why does access 2010 with postgresql odbc driver call IDENT_CURRENT?

99封情书 提交于 2021-02-08 03:28:47
问题 I am migrating an access 2003 application to access 2010. The application uses the postgres odbc driver to access its data. On access 2010 it tries to use the IDENT_CURRENT function on the postgresql server (as seen with wireshark) to identify the id of a recently inserted row ... Unfortunately IDENT_CURRENT is not a function supported by postgresql as far as I know ... I am using the latest postgresql ODBC driver (9.0) with a postgresql 8.3 database. 回答1: Using currval is the right way to go

Periodic database backup in kubernetes?

旧巷老猫 提交于 2021-02-08 03:20:14
问题 How to setup periodic database backup in kubernetes? I have deployed a postgres database as StatefulSet in kubernetes and mounted a PersistantVolume to store data. Now to get periodic backup for the mounted volume, I found three options, Setup a CronJob in kubernetes and execute pg_dump and upload to the storage location. I have already using celery in my project. So now add a new task to backup postgres data and upload to the storage location. VolumeSnapshots. This looks more kubernetes way.

Periodic database backup in kubernetes?

北城以北 提交于 2021-02-08 03:20:06
问题 How to setup periodic database backup in kubernetes? I have deployed a postgres database as StatefulSet in kubernetes and mounted a PersistantVolume to store data. Now to get periodic backup for the mounted volume, I found three options, Setup a CronJob in kubernetes and execute pg_dump and upload to the storage location. I have already using celery in my project. So now add a new task to backup postgres data and upload to the storage location. VolumeSnapshots. This looks more kubernetes way.

Postgres connection pooling - multiple users

核能气质少年 提交于 2021-02-08 03:10:04
问题 In order to secure our database we create a schema for each new customer. We then create a user for this schema and when a customer logs in via the web we use their user and hence prevent them gaining access to other areas of the database. Our issue is with connection pooling as it is a bit inefficient to keep creating/dropping new connections for these users. We would like to have a solution that can work across many hundreds of different database users. We've looked at pg_bouncer, but the

Postgres connection pooling - multiple users

我的未来我决定 提交于 2021-02-08 03:07:57
问题 In order to secure our database we create a schema for each new customer. We then create a user for this schema and when a customer logs in via the web we use their user and hence prevent them gaining access to other areas of the database. Our issue is with connection pooling as it is a bit inefficient to keep creating/dropping new connections for these users. We would like to have a solution that can work across many hundreds of different database users. We've looked at pg_bouncer, but the

Spring JPA + dynamically switch the datasource between schemas in postgresql

依然范特西╮ 提交于 2021-02-08 03:05:51
问题 I have to modify design of the existing application according to following manner, According to above design each project contains it's own schema and that mapping table (project_schema_table) is under main schema. All schemas are under one Postgresql database and in future users will create another new schemas (on demand) for their new projects. Before displaying login window I have to list all existing projects and once user select his project I have to direct to that project with relevant

Using Dapper and Postgresql - citext data type

五迷三道 提交于 2021-02-07 21:49:01
问题 I'm not sure if there is a way to support this, but I'm having trouble getting Dapper to map string parameter values to the Postgresql citext data type as it seems to be using the text type. In particular, I'm trying to call a function that takes in citext parameters - the error I get back is: var c = ConnectionManager<T>.Open(); string sql = @"select * from ""dbo"".""MyFunction""(@schemaName, @tableName);"; var param = new { schemaName = schema, tableName = table }; string insecureSalt = c