Stack Overflow Community » PostgreSQL
165 FOLLOWERS
Stack Overflow is a public platform building the definitive collection of coding questions & answers. This community is a place to ask questions and get advice for all your queries regarding PostgreSQL, a powerful, open-source object-relational database system.
Stack Overflow Community » PostgreSQL
5m ago
Am deploying a blazor app in Azure, connecting to Postgresql in Azure. Current setup, developers connect to dev instance postgresql (On prem or local install) using connectionstring (with UID & password) in appsettings.json. Once deployed to Azure, connectionstring gets overwritten by Web App connectionstring configuration in Azure, and has UID and password for Azure Postgresql DB. For better security, I am looking into using managed identity to move away from storing password anywhere in Azure. Reading this article (https://learn.microsoft.com/en-us/azure/postgresql/single-server/how-to-c ..read more
Stack Overflow Community » PostgreSQL
5m ago
I'm setting up a Patroni cluster and facing an issue where both nodes remain in the 'stopped' state, and the logs indicate that the system is waiting for a leader to bootstrap. Here is the output when I run patronictl -c /etc/postgres0.yml list:
Cluster: postgres (7366xxxxxxxxxxxxxxx) ---------+----+-----------+
| Member | Host | Role | State | TL | Lag in MB |
+-------------+----------------+---------+---------+----+-----------+
| postgresql0 | xxx.xxx.xx.57 | Replica | stopped | | unknown |
| postgresql1 | xxx.xxx.xx.129 | Replica | stopped | | unknown ..read more
Stack Overflow Community » PostgreSQL
5m ago
I have the following Knex migration (using Postgresql):
import { Knex } from 'knex';
export async function up(knex: Knex): Promise<void> {
await knex.schema.createTable('cars', (table: any) => {
table.string('id', 25).primary();
table.jsonb('car').notNullable().unique(["car->>'year'","car->>'model'","car->>'color'"], {indexName: 'unique_cars'});
});
}
export async function down(knex: Knex): Promise<void> {
await knex.schema.dropTableIfExists('cars');
}
When I run the migration I get a unique index BUT it is based off of car and not the fields ..read more
Stack Overflow Community » PostgreSQL
1h ago
I have a django project which stores real-time data of a few devices. For this manner I have used timescaledb which is suitable for time series and it's based on postgres. Timescale offers a few hyperfunctions which I need to use (specifically lttb which is used for downsampling data).
For example, this is one of the queries that I am looking to achieve:
SELECT time as timestamp, value as value, %s as device_id
FROM unnest((SELECT lttb(timestamp, value, %s)
FROM core_devicedata where device_id=%s and timestamp between %s and %s))
I can get result of this query as a raw query set by:
for d ..read more
Stack Overflow Community » PostgreSQL
3h ago
I can create a unique index on a Postgresql Json column with this:
@@unique([car])
But, I need to create a unique index based on the year, model and color:
@@unique([car->>'year', car->>'model', car->>'color'])
I instead get:
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Error validating: This line is not a valid field or attribute definition.
--> schema.prisma:25 ..read more
Stack Overflow Community » PostgreSQL
3h ago
THE PROBLEM
When trying to connect to my cloud SQL database, I'm getting the following error.
Error: listen EADDRINUSE: address already in use /Users/josechavez/projectName/projectName/.s.PGSQL.5432
at Server.setupListenHandle [as _listen2] (node:net:1812:21)
at listenInCluster (node:net:1877:12)
at Server.listen (node:net:1976:5)
at node:internal/util:410:7
at new Promise (<anonymous>)
at Server.<anonymous> (node:internal/util:396:12)
at Connector.startLocalProxy (webpack-internal:///(rsc)/./node_modules/@google-cloud/cloud-sql-connector/dist/mjs/connector.js:207:22)
at process.p ..read more
Stack Overflow Community » PostgreSQL
8h ago
After I notice the database connection url was wrong, I updated the url, the kafka project keep failing on run query.
I have 6 million of lines to send, but the connector fails every time on the exec query.
my config now
{
"name": "connector",
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"topic.prefix": "audit",
"transforms.createKey.type": "org.apache.kafka.connect.transforms.ValueToKey",
"transforms.extractTopic.type": "org.apache.kafka.connect.transforms.ExtractTopic$Value",
"transforms": "header,createKey,extractKey,extractValue",
"transforms.extractValue.type": "or ..read more
Stack Overflow Community » PostgreSQL
8h ago
I have the following tables in my PostgreSQL database:
buildings
id | name | abbreviation
----+--------------------------+--------------
31 | 4705 Fifth Avenue - Dept | 4705FIFTH-D
28 | 4705 Fifth Avenue | 4705FIFTH
...
buildings_networks
id | buildings_id | networks_id
-----+--------------+-------------
143 | 31 | 159
144 | 31 | 160
147 | 28 | 153
148 | 28 | 154
149 | 28 | 155
159 | 31 | 179
...
networks
id | name ..read more
Stack Overflow Community » PostgreSQL
8h ago
Every time I try to access the data stored in the variable I get an empty array. Is there a way around this? I have tried using pg.Pool but it didn't work. I was expecting the numberOfUsers variable to contain the result from the query. This is the code enter image description here
const userDb = new pg.Client({
user: "postgres",
host: "localhost",
database: "Project DB",
password: "1567tay",
port: 5432,
});
userDb.connect();
function userNameCount(userName){
let numberOfUsers = [];
userDb.query("SELECT COUNT(*) FROM Users WHERE username = $1", [userName], (err, res) => ..read more
Stack Overflow Community » PostgreSQL
8h ago
In xata reverse link can't sort results with createdAt date. Followed as official guide (https://xata.io/docs/concepts/data-model#links-and-relationships) but no luck. Giving error,
FetcherError: Internal Error (Request ID: f3b4a5dc-99e9-94a4-87a8-cfa06828ce11)
at eval (webpack-internal:///(action-browser)/./node_modules/.pnpm/@xata.io+client@0.29.4_typescript@5.4.5/node_modules/@xata.io/client/dist/index.mjs:2778:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async defaultTrace (webpack-internal:///(action-browser)/./node_modules/.pnpm/@xata ..read more