How to correctly call a function in PostgreSQL
I have created a function that does not give any errors itself but when calling it I get an error. I know I technically don't need a function but for my scenario I need to be using one. The error:…
I have created a function that does not give any errors itself but when calling it I get an error. I know I technically don't need a function but for my scenario I need to be using one. The error:…
users.sql -- name: CreateUser :one INSERT INTO "users" ("id", "created_at", "updated_at", "name") VALUES ($1, $2, $3, $4) RETURNING *; sqlc.yaml version: "2" sql: - engine: "postgresql" queries: "sql/queries" schema: "sql/schema" gen: go: # package: "internal" out: "internal/database" sql_package: "pgx/v5" 001_users.sql…
I have very simple table: create table tmp( id int, source_id int, event_user varchar, event_date timestamp ); and here is the data: insert into tmp(id, source_id, event_user, event_date) values (1, 1, 'A', now()), (2, 1, 'A', now()+interval '1 day'), (3,…
I have a column size of type string containing 50 or 50-56 in a string. I would like to return all items where size is 50 or size is between 50 and 56. What would be the best way to…
Imagine I have rows of data in a postgres table, such as: Id Value 1 User_1 2 Region_3 3 User_2 And I want to select out values in a way that uses the part of Value before the _ character…
I have made a Django project with a postgresql backend and am trying to containerize it. This is my Dockerfile: FROM python:3.9 ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 WORKDIR /app COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt COPY…
I have large query that need's to be optimized. Upon generating explain plan using EXPLAIN(ANALYZE) I noticed that the query is using the disk space in sorting. Sort Method: external merge Disk: 201,816kB Worker 0: Sort Method: external merge Disk:…
I have docker-compose.yaml file containing this data: services: db: image: postgres restart: always environment: POSTGRES_PASSWORD: p2ostgres1 ports: - '6000:5432' volumes: - pgdata:/var/lib/postgresql/data volumes: pgdata: after running docker-compose up and making some changes to the database, i can access that database…
With a schema: CREATE TABLE foo ( id SERIAL UNIQUE, name VARCHAR(15) NOT NULL, domain VARCHAR(255), ); CREATE TABLE bar ( foo_id INT UNIQUE NOT NULL REFERENCES foo(id), passphrase VARCHAR ); I need to use: SELECT * FROM foo LEFT…
I'm making a Django app using a postgresql database for a family who need to coordinate their grocery purchases. Say one person has on their mobile device a full list of the groceries and is in the supermarket, buying and…