Questions tagged [postgresql]
PostgreSQL is an open-source, Relational Database Management System (RDBMS) available for many platforms including Linux, UNIX, MS Windows and Mac OS X. Please mention your PostgreSQL version when asking questions. Always include the "sql" tag and possibly the "plpgsql" tag if applicable.
177 questions
2
votes
0
answers
62
views
Generic UnitOfWork implementation with Dapper. (Updated)
Here's my attempt to implement the suggested corrections I received in my previous post. Since System.Data.IDbTransaction doesn't support ...
1
vote
1
answer
74
views
Generic UnitOfWork implementation (Dapper)
I'm creating a three layered Visual Studio template solution that I'll be using as a starting point for all ASP.NET projects.
The layers are Presentation, Application and Infrastructure. ...
5
votes
0
answers
82
views
Correct abstractions/organisation of a NodeJS GraphQL API
I recently did a quick take-home test for a potential job opportunity. It included building a GraphQL API with nodeJS. I am not an expert in node (mostly use Python at work) but I have used it for ...
10
votes
2
answers
1k
views
Multithreaded UDP server that advertises itself in a PostgreSQL database and launches other servers in response to messages from a client
Description
For fun, and to learn some C++, I've decided to reimplement the entirety of EVE online as I remember it. (I'm aware this is an insane and likely unreachable goal, that's intentional).
I'...
3
votes
1
answer
183
views
Serialized document inventory management splicing/slicing function
Unlike other inventory management systems that their items are fungible, in this system they are not supposed to. Each item is serialized and tracked since the printing press. We are trying to move ...
5
votes
2
answers
701
views
A schema for awallet system that allows transfers between users
I am currently working on a wallet system that allows transfers of money between users. I tried creating this as a Stack Overflow question, but it was rejected. I'm not sure if this is the right ...
3
votes
1
answer
77
views
Postgresql generated column from Finnish personal identity code
The Finnish personal identity code is defined as:
Day, month, and year of birth, in ddmmyy form (six digits, zero padded if necessary)
A separator
For those born &...
3
votes
1
answer
68
views
PostgreSQL Search Feature
The Problem
I am developing a search feature in PostgreSQL that involves a collection of JSONB documents stored in a table, which have been standardised. The goal is to enable clients to perform ...
2
votes
1
answer
73
views
Find and conditionally sort all venues matching a filter provided by an API client in PostgreSQL
I have an API where users can retrieve a list of "venues".
Every venue is a profile, but not every profile is a venue
Venues can be "parents" of other venues (think hotel - floor -...
1
vote
0
answers
100
views
Todo application using Spring Boot 3, Dockerized Postgres, Java 17, Maven
I'd like to have code review for backend of todo app.
It has 2 main functionalities:
Authentication and authorization using Spring Security and JWT token.
CRUD for tasks
In particular I'd like to ...
1
vote
2
answers
39
views
Creating single table vs creating multiple table
I have lots of services which I am integrating. (also I am new to sql)
For each service integration I get different response,
For example, for zoom, I would just need to store the access_Token, for ...
2
votes
1
answer
75
views
Update table with data from another table under certain criteria
I need to update a lot of data from one table based on criteria from another table.
My tables and records in those tables look like this:
This is Users table where i can have many records for single ...
1
vote
0
answers
45
views
Get the difference between two sets from database
Hello beautiful people!
I have created a script where I have two database functions (Feed and Product) where I have a list of Feeds in a store and a list of Product in the store. What I have done is ...
2
votes
1
answer
157
views
Extracting authors and books from XML and inserting them into PostgreSQL
There is a tree of start folder, it's subfolders, their subfolders, etc. In each folder, subfolder, etc. there are the same structured XML files stored.
books.xml
...
4
votes
1
answer
223
views
Postgres DB design
I need to develop a database to handle muting people in an online community. The DB needs to keep track of the currently muted people. When somebody gets unmuted, that entry gets moved to an archive ...
2
votes
0
answers
124
views
A Python base class for a family of Postgres server manager classes
I'm working on a repo the purpose of which is to create and manage a local PostGIS server. (PostGIS is a bit niche, but it boils down to a few extra spatial data types and built-in SQL function. With ...
1
vote
1
answer
197
views
Get Gzip file from endpoint, extract data and add to database
I currently have a script that fires a request to an API endpoint which returns a csv.gzip file - which roughly contains 75,000 rows and 15 columns. I download this ...
1
vote
1
answer
56
views
PostgreSQL query which return metrics joining different tables
I have a query that can be seen on this fiddle and I'm relatively new to PSQL, having a few months of experience.
DB Fiddle
As mentioned in the comment I should put the query here and the code is ...
2
votes
0
answers
31
views
Plpgsql function that redacts substrings wrapped with double pipes `||`
I'm using Postgres 14 and I've written a function (for use with Hasura GraphQL Computed Fields) that transforms a TEXT field, replacing all instances of spoiler-annotated text (e.g. ...
1
vote
0
answers
108
views
Go REST API feedback [closed]
My intention is to create an API as generic and DRY as possible using Go. To achieve this, I have made some more or less common decisions:
To use AJAX call to avoid reloading page when updating the ...
2
votes
0
answers
54
views
Implementing a tables inheritance mechanism with PostgreSQL which allows to always reference the parent table in a foreign key
Context
Postgresql has an INHERITS keyword which lets you inherit one table from another, but it is known to have several caveats, mainly because it is not a true ...
4
votes
1
answer
142
views
Django User Model to authenticate using email address and password
This is my second Django project for an actual client and I want some review on one of my important models.
This model will be responsible for authenticating users using their E-Mail Addresses and ...
4
votes
2
answers
179
views
Historical database design for school system
Context
We are a multi-academy trust designing a database system (more of a warehousing solution) to aggregate educational data from our 13 schools into a single source.
The data will be mostly ...
0
votes
1
answer
38
views
Comparing two columns across tables for a remaining subset
How can I find the unique phone numbers (and collapse them into a single column) from table_1 (while keeping the IDs and date fields), and remove phone numbers that appear in table_2?
table_1
id
...
2
votes
1
answer
57
views
Find coherent datetime ranges in postgresql
My Data consists of rows containing a Length/Duration in Minutes, a Begin & EndTime. The precision is 1min (or larger).
the table looks something like that:
...
5
votes
1
answer
146
views
PostgreSQL: Grouping and Aggregating on multiple columns
Problem Statement:
I am working on this simple dataset from Kaggle. I have provided a snippet of data with only required columns in below table. Dataset is quite simple, it has all IPL (cricket) ...
1
vote
1
answer
75
views
Simple website sql database
I'm getting into backend with postgresql and I would like to know how much of my example would fit for a real website database, just for storing and then displaying it on website.
...
1
vote
2
answers
89
views
Querying and rendering an HTML table of ISP performance statistics
I have multiples measurements and I want to render it into tables like this
Measurements
Operator
browsings
FTP DL
FTP UL
Location
Event
Date
Operator
avg
min
max
avg
min
max
avg
min
max
Verizon
...
1
vote
1
answer
94
views
Queries using ORM and PostgreSQL
After yesterday suggestions, I was told... recommended to move over to ORM and I did. I choosed to use PeeWee together with PostgreSQL. Queries for storing and get information from postgreSQL
This is ...
1
vote
2
answers
2k
views
A discord.py bot that logs every messages sent in a discord server
Hello Code Review community !
I'm making a bot with discord.py that listens to every message sent in a server and stores it in a database that could be retrieved by admin/mod later.
Here's the ...
2
votes
1
answer
157
views
Getting new vs. returning customers in Postgres
I have this work task, to write a SQL query that would show how many of the active customers are new (= do not have prior transactions) as opposed to returning per a given period.
There is nothing ...
6
votes
1
answer
1k
views
Simple Connection Pooling with psycopg2 and PostgreSQL
I am currently using a SimpleConnectionPool from psycopg2 to lease transactions to a PostgreSQL database and would like a review ...
1
vote
1
answer
29
views
Avoding CT and other sins?
I'm a SQL learner. In answering the question* For the region with the largest sales total_amt_usd, how many total orders were placed? for the following schema:
(I am unsure of the dialect is but I ...
2
votes
1
answer
960
views
Creating SQL Table from a Go Struct
I have been building an API in Go, which I want to link to a Postgres SQL table. I have always used NoSQL previously but thought ...
2
votes
1
answer
102
views
Managing a store in PostgreSQL
I have been trying to improve python combined with Postgres.
At this moment im only sending two values to database which are etc:
...
4
votes
1
answer
799
views
Historical Funding Rate Miner for ftx.com
I recently started to take a look at the Go programming language and decided to write a small project without practical use.
The objectives were:
Regularly poll the latest funding rates from https://...
3
votes
0
answers
146
views
Updating user information in SQL
Newbie here. I have this gqlgen api with sqlc update code, which updates the user by given id with provided fields:
...
6
votes
1
answer
842
views
Air Quality/Environment Monitoring Web App using Plotly Dash
Overview & Motivation
This project manages and displays sensor data (temperature, humidity, Air Quality Index). The sensor data is displayed by the sensor manufacturer, PurpleAir, but their tool ...
2
votes
1
answer
147
views
Any ideas how do I prettify this SQL query?
This question is abut coding style. I'd like to see how would you improve this code look considering readability as well. Feel free to upvote others solutions you find good.
#1 Initial version:
...
2
votes
0
answers
34
views
A task to store user's favorited projects in postgres using python
I am not happy with two functions calling get_user() since while testing I mock get_user and to test with get_user_returns_null case, it returns Null for both ...
4
votes
1
answer
361
views
Discord bot with Psycopg
I've made a Discord Bot in Python that uses the Psycopg module to make calls to a PostgreSQL database in order to display information.
https://github.com/Chombler/cardbot
Specifically, I call this ...
2
votes
1
answer
112
views
Selecting changes from a temporal table
I'm using Temporal Tables on postgresql (https://github.com/arkhipov/temporal_tables) and C# with dapper.
I'm storing an entity together with its changes.
Here's an example entity, with an Id and two ...
3
votes
1
answer
81
views
Getting weather and cycling data (yr.no, oslobysykkel)
What I am trying to do, is to get weather data, data about bike trips and populate the postgresql database in order to be able to work with this data from Power BI/Tableau/any other tool.
I have two ...
3
votes
2
answers
105
views
Fetching all nodes of a directed graph by an id of any node
Task: Rowset of all reachable(in any direction) nodes from any node in a graph. In other words I need to extract all nodes of a particular graph from a table in the database where graph specified by ...
1
vote
1
answer
38
views
SQL Negation: Find X when X does not do Y
I'm learning The essence of SQL by Rozenshtein indirectly from the SQL Cookbook which has a section on it with modern SQL ...
2
votes
0
answers
45
views
Handling failures in DB transactions
This code is meant to retry the db operation when a DB connection breaks: OperationalError.
A transaction can fail for example when a db is being restarted and a commit fails. Or when a network error ...
4
votes
1
answer
138
views
Postgres Shopping Database using Python
So I have just started to work with SQL and I have tested my script and is working very well when it comes to my database.
The database is used for shopping. What I mean by that is that I scrape a ...
1
vote
0
answers
243
views
querying users from table if user.id is found in another table
I am using flask with sqlAlchemy to connect with a postgresql database with two tables
Users table (id, name)
...
3
votes
1
answer
106
views
Modelling user preference system with categories
I am modelling a user preference system with the following requirements
a user can have attributes (foods they eat)
a user can have dynamic categories of preferences
users which have all their ...
3
votes
0
answers
60
views
Django migration script to add metadata
I made a simple django migration that adds two field to our Invoices model : first_payment and first_paying_month.
...