Category "postgresql"

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

How can I check postgres database in docker volume?

I followed the tutorial from prisma.io to get started building a local server. Follow the docker-compose.yml: version: '3' services: prisma: image: pris

Using LIMIT / ORDER BY with pg Postgres NodeJS as a Parameter

I have a model with calls the products with SORT/PAGE/PER PAGE It works fine with numerical values as parameters but not strings. This works fine... params.lim

Column is of type timestamp without time zone but expression is of type character

I'm trying to insert records on my trying to implement an SCD2 on Redshift but get an error. The target table's DDL is CREATE TABLE ditemp.ts_scd2_test (

postgres C:: Permission denied using windows

I am using Windows 10 I have a PostgreSQL file when I run inside the PSQL CMD \i FILENAMEPATH postgres=# \i C:\Users\Asus\Desktop\Projects\Movies\solution.sql C

SQLAlchemy (psycopg2.ProgrammingError) can't adapt type 'dict'

Couldn't find a solution on the web for my problem. I am trying to insert this pandas df to a Postgresql table using SQLAlchemy Pandas 0.24.2 sqlalchemy 1.3.

Postgres Subquery - How to create ALIAS in object format from subqueries

I am trying to wrap several queries into 1 complex query. Here is the scenario. Given a user_id of 'xxxxx-xx-xxxxx' I have to query for several data points with

Postgres Join tables and create new field if join exists

I'm new to Postgres and I have a confusing one. Basically, I want to find if my post is bookmarked by the user or not in a new field bookmarked = true / false H

Deterministic sort order for window functions

I've a status table and I want to fetch the latest details. Slno | ID | Status | date 1 | 1 | Pass | 15-06-2015 11:11:00 - this is inserted first 2

Transpose rows to columns in PostgreSQL?

Does any one know how to transpose rows to columns in PostgreSQL? For example I have the following table:- Period T1 T2 D

Trying to persist not discovered entity of type object

The problem I'm new to Nest.js and Mikro-ORM, which I have to learn as a job requirement. This stack requires TypeScript, which I despise from the bottom of my

What's the difference between BIGINT and INT8? (postgres)

I'm using a service called Supabase and I created a table: CREATE TABLE my_table ( "id" BIGSERIAL PRIMARY KEY NOT NULL, "title" Text COLLATE "pg_catalo