Category "postgresql"

Connect to Postgres from Swift

In a Swift app, how does one connect to a Postgres database server? In Java, we use JDBC with an compliant driver to connect to a Postgres server, communicate

postgresql show month start date and end date based on given dates

I need to pull out first date and last date of the month from the given from_date and to_date as input, For Example:- I have my psql output table as the followi

Django/Docker/Postgresql: app connected to the 'wrong' database

I have develop a project with Django/Docker/Postgresql and use docker-compose to deploy on a linux remote server. I want to deploy 2 apps based on the same code

How to use to_jsonb as row_to_jsonb? Where the details about "how much"?

I was testing some queries at pg9.4 in "JSON mode", and now I am checking if pg9.5 will bring all same JSONB functionality... But there are no row_to_jsonb() fu

Calculating Percentage value for a Group by value in Postgres

I want to calculate Percentage of a value in Group by. My Table data salesId salesAmount productName salesTyp ------- ----------- ----------- ----

cant create a database in DBeaver

im just starting using databases and I'm working with PostgreSQL using Dbeaver. When I want to create database,i need to create a new connection ,so I select Po

Parse postgres URL

I'm trying to parse postgres db credentials, the format is as follows: postgres://usernname:password@hostaddress:port/databasename I'm calling a method which r

Which Postgresql WAL files can I safely remove from the WAL archive folder

Current situation So I have WAL archiving set up to an independent internal harddrive on a data logging computer running Postgres. The harddrive containing the

get time for timezone

I'm hurting my head again this : On postgresql, I would like to get the local time for a given timezone. So, at 15:45 GMT, I want 16:45 for +01:00, but I can't

BeanCreationException: Error creating bean with name 'flywayInitializer'

I am trying to run my project tests in a docker container. All of the tests work just fine when running locally. Errors started occurring when I tried to move m

PostgreSQL left join query object array aggregate

I have 2 tables: table "person" with columns: person_id, person_name table "pet" with columns: pet_id, owner_id, pet_name person data: 1, 'John' 2, 'Jill' 3,

Bulk insert, update if on conflict (bulk upsert) on Postgres

I am writing a data-mining program, which bulk inserts user data. The current SQL is just a plain bulk insert: insert into USERS( id, username, profile_pi

bcrypt and postgresql. What data type should be used?

On flask-bcrypt extension, the encrypted string is stored as bytes object like this (with python 3.5): >>> user.password b'$2b$12$3UutBDuGIrxp2z95alVT

bcrypt and postgresql. What data type should be used?

On flask-bcrypt extension, the encrypted string is stored as bytes object like this (with python 3.5): >>> user.password b'$2b$12$3UutBDuGIrxp2z95alVT

Syntax error at end of input with IF ... ELSE statement

I'm running this code: CREATE OR REPLACE FUNCTION trg_orders_check() RETURNS trigger LANGUAGE plpgsql AS $func$ BEGIN IF NEW.type = 'prescription' AND NEW

Postgres query cost is higher but runs faster

Update on 2022-05-15 After running vacuum analyze, the query plans are below. For A query Nested Loop Left Join (cost=45913.11..496597.16 rows=10 width=128) (a

Convert Number type to Date in postgres SQL

I have a numeric data in a column 20170930, need help in converting it into Date in PostgreSQL , tried multiple ways but non seems to work

Inserting array values

How do I write and execute a query which inserts array values using libpqxx? INSERT INTO exampleTable(exampleArray[3]) VALUES('{1, 2, 3}'); This example code

Rails + Postgres migration - why am I receiving the error "PG::UndefinedFunction: ERROR: function gen_random_uuid() does not exist"?

One of my Rails migrations uses a uuid as the primary key. The Postgres extension gen_random_uuid() should solve this issue, but I continue to get the error aft

GROUP by multiple ranges in postgresql

I have max and min values of prices in postgresql, and group the count of result set according to different ranges of prices between this max and min values, my