PostgreSQL is an open-source, object-relational database management system (ORDBMS) available for all major platforms including Linux, UNIX, Windows and OS X. Please mention your exact version of Postgres when asking questions. Questions concerning administration or advanced features are best ...
0
votes
0answers
18 views
Is there a SQL table constraint to ensure that a relationship exists between two columns?
I'm trying to solve the following problem.
CREATE TABLE leagues (
id SERIAL PRIMARY KEY,
name TEXT,
...
);
CREATE TABLE players (
id SERIAL PRIMARY KEY,
first_name TEXT,
...
0
votes
0answers
7 views
Copy csv to PostgreSQL table using Python
I am trying to copy csv file to PostgreSQL table with Python. I've created the empty table in PostgreSQL DB, I just need to copy the data, which have no headers, from the csv file into the PostgreSQL ...
0
votes
1answer
10 views
Can we use parse server for postgresql
Currently I am using MongoDB with parse-server as back-end in my node.js application, because of business requirement I have to change my database from mongodb to postgresql. Is there any way by which ...
-1
votes
2answers
20 views
Postgresql how to?
Given the following tables:
\d users
Table "public.users"
Column | Type | Modifiers
--------------------+----------...
1
vote
0answers
15 views
scripting node.js into postgres
I'm probably outta my league here as I haven't been programming long so maybe there are many errors. Any that can be spotted would be a huge help. It's my first time with node.js and I'm not sure ...
0
votes
0answers
13 views
Jaspersof iReport-How can I RETURN ALL records when parameter is null
I have three parameters $P{Clss} (select the class from ships), $P{MinWeight} and $P{MaxWeight}. Whenever I leave the $P{Clss} blank it always display no pages.
Whats wrong with my WHERE clause? I'...
1
vote
4answers
31 views
Given a Model.title, how to best query for all records with the first letter = X
I have a table w 200 records. Each record has a title field which is populated. I would like to dynamically pull all records that start with a certain letter. What's the best way to do this with rails/...
0
votes
1answer
10 views
find rows not following by the same values in 3 columns
I have a table named raw_data with the following data
as You can see id 1 and 2 share the same values in field desa, kecamatan and kabupaten, also id 3,4,5.
So basically I want to select all rows ...
1
vote
2answers
31 views
What does LIKE '%%' mean in postgresql?
What does '% %' mean in postgresql? Does it just mean LIKE '%'?
0
votes
0answers
8 views
PostgreSQL CSV Export Joining all Linked Tables
I have a PostgreSQL users database that contains many linked tables based on a each user's unique ID. I can successfully export each table to CSV format however for any columns containing linked data, ...
0
votes
0answers
13 views
Postgres lc_numeric not working as expected
I'm on a project that involves a database that uses Danish numeric settings (the decimal separator is a comma). I'm trying to figure out how I can store values in the database as decimal/number/...
-1
votes
0answers
11 views
Complex query with rest
I am new to REST and I am trying to use it to access an online database on heroku from an android app. My query however is relatively complex and i don't understand where to start from, and not even ...
1
vote
0answers
14 views
Lack of performance in PostgreSql redis_fdw
Is it normal that inserting a single two-column line in a redis_fdw scalar/hash table lasts longer than in a regular Postgres table (in average 0.6 ms vs 0.06 ms)? I use Redis to speed-up my postgres, ...
0
votes
2answers
18 views
Update postgres table to squash duplicate values in second table
I have a postgresql schema with two tables:
tableA: tableB:
| id | username | | fk_id | resource |
| 1 | user1 | | 2 | item1 |
| 2 | user1 | ...
0
votes
0answers
23 views
how to properly implement soft delete in postgresql?
in my postgres 9.3 database, I have the following combination of function and a trigger to implement soft delete functionality:
ALTER TABLE "LIBN02"."trigger_test_1"
ADD COLUMN delete_ind integer
...
0
votes
1answer
23 views
Rails query user first name on join model
this situation that find the user on a join model is seems tricky than usual
class ConversationParticipant < ActiveRecord::Base
belongs_to :user
belongs_to :conversation
...
0
votes
1answer
18 views
Make a new column using values from other tables
I have a table which I have created using a union all from two tables. I am trying to insert a new column in the new table created using a case statement. My requirement is if the addresses of the new ...
-2
votes
0answers
28 views
postgresql performance contradiction
I have two servers. On the first one I have postgresql version 9.6 . On the second one I have version 9.3 . I ran pgbench on both servers.
First server results:
scaling factor: 1
query mode: simple
...
0
votes
0answers
9 views
Postgres cursor multiple app server readers
I'm trying to spread the load of processing millions of records onto multiple application servers. The records are created by means of a complex join. That is the data cannot simply be retrieved from ...
0
votes
0answers
9 views
Using Npgsql to access postgresql from Power Query
Using Excel 2016 and trying to access a remote postgresql server with Power Query. Power Query prompts me to install npgsql. Installed the component in the GAC. Once restarted, Power Query allows me ...
-1
votes
0answers
13 views
Work out median in sql [duplicate]
For this challenge you need to create a simple SELECT statement. Your task is to calculate the MIN, MEDIAN and MAX scores of the students from the results table.
Tables and relationship below:
...
1
vote
1answer
14 views
SQL - check if an order date occurs after the second Saturday in July
I am querying against a table of 4 yrs of order transactions (pk = order number) and I'm looking to tag each record with particular date flags based on the order date - e.g., calendar year, calendar ...
0
votes
0answers
22 views
deploying django app with gunicorn and nginx
Okay so I have been working on this for awhile now and I know many people have had similar problems to myself but I can't seem to find the right solution.
Anyway I have followed the tutorial exactly ...
0
votes
1answer
16 views
Get primary key from SqlAlchemy before commit the object
I have been using sqlalchemy with postgres and dont know how to solve the issue bellow.
I want to get the value of primary key before commit to DB.
I have a class called process that has proc_id and ...
0
votes
0answers
16 views
exporting local database for heroku
I am trying to run pg:psql on heroku CLI in order export a database for local use.
I get the error "The local psql command could not be located"
In order to address this I updated my bin path in ...
0
votes
1answer
13 views
pgsql internal and c stored procedure support - can they modify PostgreSQL internals?
pgsql stored procedure has support for internal and c languages.
These are very interesting, however I cannot find many examples of what they can do. Furthermore, I was wondering if they would allow ...
0
votes
0answers
24 views
How to group similar records in django ORM
I am building a website that compares odds and returns best odd for a particular event. I get my data from an API that I use to feed to the db.I am receiving example data in this format:
**Website** ...
1
vote
1answer
27 views
Connection validation error using postgresql jdbc 4.2 driver against a 9.3 database — apparent case-sensitivity of SEARCH_PATH keyword
Using the jdbc4.2 implementation contained in postgresql-9.4.1212.jar, I generate an error when calling the java.Sql.Connection isValid() method on a connection to a postgresql 9.3 database (java8 and ...
0
votes
1answer
6 views
Multiple rule replace within single column postgresql
I am trying to select a column and do a multiple replacement i.e
Col1
a
b
c
d
select col1 and replace a = 1, b=2 and c=3
Col1
1
2
3
d
I am aware of update and replace but only for a single rule at ...
-1
votes
1answer
28 views
How to create database,table with primary key and auto increment in SQL
I would like to create a table that they have an ID int primary key, However, I would like to insert the values manually, that means I don't need the ID incremented by itself?
0
votes
1answer
17 views
HTTP POST Data from Arduino to Django Database
I know it is frowned upon to post questions without code, but I have been stuck for days thinking of how to handle this issue and cant think of a solution.
My setup is this:
Arduino Mega w/ 4G + ...
0
votes
1answer
18 views
How to count total string value / group using an Active Record query?
Is there a way to count how many specific string value from the database column using Active Record (Using PostgreSQL as my database)?
If I wanted to show in my view the how many taco lovers there ...
0
votes
0answers
13 views
Recursive proximity search with PostgreSQL
I have the "options" table with a recursive relation over itself, it can conceptually defined as a table with three properties:
options (id, parent, value)
This structure helps me building up a sort ...
0
votes
1answer
13 views
Organize data from a bookkeeping system
I'm working with a bookkeeping system like these data below (the grouping and reconciled column doesn't exist):
Date num (pk) document supplier debit credit balance ...
-1
votes
0answers
24 views
SQL Basics: Group By Day
There is an events table used to track different key activities taken on a website. For this task you need to filter the name field to only show "trained" events. Events should be grouped by the day ...
0
votes
1answer
11 views
postgresql 9.3 log slow queries
I am using Rails application with Postgres 9.3 database and doing some performance fixes. I would like to know how to find out slowest queries in log files. let say queries taking more then 30ms.
0
votes
0answers
12 views
Capture failure cause - psql: FATAL: the database system is shutting down
I would like to write a sh script and capture the failure cause of psql
psql -Upostgres -h172.18.255.80 -p5432
psql: FATAL: the database system is shutting down
If I can get the text into a ...
0
votes
0answers
10 views
Casting text to dates in postgres where precision changes
I have a text column which records dates in varying precision.
12/07/1951
--/06/1976
I want to move them to a postgres date type column. I can use to_date() when I know the composition of the source ...
0
votes
1answer
20 views
Spring Boot MVC application with Postgresql deployment failed in Heroku
I have a Spring Boot MVC project. It works fine with h2 database and also fine in local postgre database with following application.properties configuration
spring.datasource.url=myUrl
spring....
0
votes
0answers
13 views
How to aggregate jsonb object?
I have jsonb field in table with values like that:
{
"1":[{"start":64800,"finish":68400},{"start":61200,"finish":64800},{"start":75600,"finish":79200},{"start":79200,"finish":82800}],
"2":[{"start":...
0
votes
1answer
23 views
How to enforce soft deletes on postgres?
I want to prevent sql row deletes on a table in a Postgres database, to ensure that there is no other way of deleting rows, other than soft deletes, which are in effect an update to the "active" ...
1
vote
0answers
17 views
Can I change Linux time in a Postgresql production server?
Today I found out that a linux's server clock, hosting a PostgreSql cluster in a production environment, is late and I need take it to the current time.
I've used these lines in my local machine:
...
1
vote
1answer
19 views
PostgreSQL difficulty extracting field from jsonb column
Using PostgreSQL 9.5.5
Given the below example jsonb data in a column:
{
"item_id": "123456",
"action_information_1": [ {"value": "259", "action_type": "read"} ],
"action_information_2": [ {"value"...
-1
votes
0answers
25 views
Merging two queries to show the results side by side. Speed is important. Using PostgreSQL
I am looking to join many queries side by side (horizontally) aligned/joined by a single index, gq.id in this case. I'd like the results to show nulls if one query has a missing value (outer join).
I'...
1
vote
1answer
24 views
500 The operation couldn’t be completed. (PostgreSQL.DatabaseError error 1.)
While doing Ray Wenderlich tutorial "Server Side Swift with Vapor: Persisting Models" I tried to add one more parameter(param) to the class Acronyms.
import Vapor
final class Acronym: Model {
var ...
0
votes
0answers
12 views
Sequelize - beforeUpsert hook not firing
I'm trying to encrypt passwords beforeUpsert:
beforeUpsert(user, fields, fn) {
if(!user.password) {
user.password = config.secrets.session;
return user.updatePassword(fn);
}
...
-1
votes
2answers
28 views
Escape single quote in Postgres query inside node js app
Here is a line from my node js code:
var qry = 'INSERT INTO "sma"."RMD"("UserId","Favourite") VALUES (' + req.body.user + ',' + JSON.stringify(req.body.favourite) + ')'
I want to insert single ...
1
vote
0answers
23 views
ERROR: from _pg import * ImportError: DLL load failed: The specified module could not be found
I'm having the exact same problem as described here:
ver.2 PyGreSQL ERROR: from _pg import * ImportError: DLL load failed: The specified module could not be found
the error:
from _pg import * ...
0
votes
0answers
9 views
SYmmetricDS SSL OFF
I am running the SymmetricDS in my system, i am facing the below error message. Can you please help me some on this issue.
[till11] - AbstractSymmetricEngine - Could not get a connection to the ...
0
votes
2answers
40 views
PostgreSQL - How to remove duplicates when doing LEFT OUTER JOIN with WHERE clause?
I have 2 tables:
users table
+--------+---------+
| id | integer |
+--------+---------+
| phone | string |
+--------+---------+
| active | boolean |
+--------+---------+
statuses table
+-------...