PostgreSQL – how build a where clause from nested array
I have a query: SELECT … FROM … WHERE project = 123 AND ( file = file1 and fieldidx = idx1 OR file = file2 and fieldidx = idx2 OR …) … I want to create the where clause in…
I have a query: SELECT … FROM … WHERE project = 123 AND ( file = file1 and fieldidx = idx1 OR file = file2 and fieldidx = idx2 OR …) … I want to create the where clause in…
I have a docker compose file, which spins up postgres db. How can I run some psql commands after this container is started? This is what I'm trying to run: createuser postgres createdb DB createdb TEST_DB psql -d DB -c…
I am attempting to create database in postgres docker container using createdb command. It creates database, but I also get an error message: psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory and I am…
I was provided a .sql script containing a query to create a table. I trust the source of the script, so I am wondering if the problem is how/where I'm running it. I'm running it in psql, using a call…
I have a table cities with records like: Name Value id 62 name Alberta There are many more but the format is the same. I have an API in Node.js in which I receive a city name. Now, the city…
I have a Postgres DB with multiple databases, whose schemas are owned by individual service users. Now, I want to create a user which can access all those databases/schemas with atleast SELECT permissions. Is there any effective way of assigning…
I have created alarm that insert into database based on type of event at the same time. I did query select * from alrm where ble=$bleAddress and datetime=(select max(datetime) from alrm to get the list of data from alrm table.…
This line of command I picked from one of my bash scripts I am trying to use to automate some initial setup of a PostgreSQL database in an Amazon Linux machine. I have the environment variable named TEST_PASSWORD contains the…
My goal is to efficiently import large amounts of data into a Postgres Database. In principle, the raw data could be compressed by a factor of ~20 (e.g. using gzip). The COPY statement seems to be the best option for…
I'm unable to migrate a model due to the following exception and I'm trying to fix the issue with psql. ValueError: Found wrong number (2) of constraints for accounting_inventory(trade_id) models.py class Inventory(TimestampedModel): class Type(models.TextChoices): SNAPSHOT = 0, "Snapshot" ASSET =…