Tagged Questions
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
3 views
postgresql, jsonb field, array append via jsonb_set and jsonb_array_length
I have postgresql with jsonb field that always contains array.
I need to append new values to that array or update already existing values by index.
Looks like jsonb_set function meet my ...
0
votes
0answers
11 views
Performing PostgreSQL match using OR on a JSON field
I have a model that looks like this
class Message(db.Model):
content = db.Column(JSON)
I want to perform a search on that field which contain some JSON fields
normally when I something like ...
0
votes
0answers
6 views
SQLAlchemy date difference as a column property
How to calculate the difference between two days with SQLAlchemy as a column_property?
With simple Test model:
class Test(db.Model):
id = db.Column(db.Integer, primary_key=True)
test_date = ...
0
votes
1answer
12 views
ODBC postgres error with not-null constraint
I have a simple user table
CREATE TABLE benutzer
(
user_id character(38) NOT NULL,
user_name character varying(50) NOT NULL,
user_fullname character varying(50),
user_password character ...
4
votes
1answer
21 views
SQL: Aggregate records within a group taking into account rows order
I have a table of the following structure
| id | a | b |
| 1 | 1 | 1 |
| 2 | 1 | 5 |
| 3 | 2 | 2 |
| 4 | 2 | 3 |
| 5 | 2 | 5 |
| 6 | 1 | 3 |
| 7 | 1 | 7 |
| 8 | 3 | 1 |
| 9 | 2 | 0 |
| 10 | ...
0
votes
1answer
10 views
postgres return last id codeigniter
I'm new with postgres database codeigniter
for return last id in mysql
im using this in my model
public function daftar($data){
$this->db->insert('akun', $data);
...
0
votes
0answers
6 views
Objection js model fields data trim before saving the record in postgres in nodejs
I am using objection.js ORM for my node.js project. Everything is good, I want to trim all the fields before actually saving the data in the PostGres database table. I have also used mongoose in some ...
0
votes
0answers
8 views
sql iteration of same result set: DAX EARLIER equivalent in SQL
Assume example query and result as follows
select product p ,sum(sales) S from Data group by product;
Product,sum(sales)
coffee,10
EnergyDrink,30
Tea,20
Say i have requirement to get sum of ...
0
votes
0answers
8 views
ERROR: functions and operators can take at most one set argument error
create or replace function get_route2(snode integer, tnode integer)
returns table (id integer, source integer, target integer,cost double precision, geom geometry)as
$$
declare
snode1 integer;
...
0
votes
3answers
21 views
SQL error: having operation
I need to write a sql script, that has to show all man client, whose maximum income twice bigger, than minimum income overall.
SELECT
DISTINCT
customer_rk,
max(monthly_income_amt),
min(...
-1
votes
0answers
5 views
psycopg2 OperationalError: server closed the connection unexpectedly on odoo ubuntu server
I used postgresql and linux server in odoo. Sometime my server occur this error.
Traceback (most recent call last):
File "/opt/vinsmotor/vinsmotor-server/openerp/http.py", line 115, in dispatch_rpc
...
0
votes
2answers
26 views
Need to insert struct directly inside the postgreSQL using go lang
I am using go lang as my back end and postgreSQL as my database.I use "github.com/lib/pq" driver to connect with my database.I have a struct which have lot of field and it has some JSON inside it.My ...
1
vote
1answer
23 views
Unable to switch from SQLite to Postgres
I have been following everything in this tutorial for Postgres:https://realpython.com/blog/python/flask-by-example-part-2-postgres-sqlalchemy-and-alembic/
And I have been getting the following error....
0
votes
0answers
12 views
Rails + Postgis: error cannot drop table spatial_ref_sys
Rails 5
Postgresql 9.4.10
Postgis 2.1.8
when I try rake db:reset, console show an error
rake aborted! ActiveRecord::StatementInvalid:
PG::DependentObjectsStillExist: ERROR: cannot drop table
...
-2
votes
2answers
25 views
column must appear in group by clause error in postgresql
I know that its a common problem in postgresql but i have tried many solutions on stackoverflow but did not get result, that's why i have posted this on SO.
This is my query which i am running on ...
0
votes
1answer
20 views
How to execute two select queries at once in Postico Postgressql on Mac
I used to run my entire query in mssql which had many select statements. Each select statement created a temp table. I am trying to do the same in postgressql using Postico but it wont let me do so. I ...
-1
votes
0answers
17 views
how to install postgresql cleint on windows vm
how to install PostgreSQL client on windows ,please share the link if any or do we have any customized options to configure only client with PostgreSQL installer
1
vote
3answers
19 views
Postgresql: Match complete word contained in an array
I have a query as:
select id
from events
where description is not null
and (name ilike any (query_arr)
or description ilike any (query_arr)
or additional_info ilike any (...
1
vote
2answers
15 views
How to get rows between time intervals
I have delivery slots that has a from column (datetime).
Delivery slots are stored as 1 hour to 1 hour and 30 minute intervals, daily.
i.e. 3.00am-4.30am, 6.00am-7.30am, 9.00am-10.30am and so forth
...
1
vote
1answer
14 views
Setting input parameter types in SQLAlchemy raw SQL
I want to execute some raw SQL and take advantage of SQLAlchemy's SQL injection prevention.
My code is similar to this bit:
import sqlalchemy
from sqlalchemy.sql import text
DB_URI = '...'
engine =...
0
votes
1answer
17 views
Apostrophe throwing error in psycopg2 data insert in new style format
I'm using psycopg2 to insert data into a PostgreSQL database. The following script works fine until 'notes' contains an apostrophe, for obvious reason. However, when I try cur.mogrify instead of cur....
0
votes
2answers
23 views
What is the difference between sudo -u postgres psql and sudo psql -U postgres?
I'm new to Postgres and Bash so I'm not sure what the difference is.
I'm trying to automate in a bash script updating a table in Postgres. I have the .sql file and I've created .pgpass file with 600....
1
vote
1answer
29 views
cannot drop table because other objects depend on it
I'm trying to develop a postgres database and I'm using SQLAlchemy to map my db. The thing is that I was getting way too many errors about dependencies and started to clean some relations to debug and ...
1
vote
1answer
49 views
Detect if the row was updated or inserted
I am doing an INSERT with ON CONFLICT to postgre using java. Is there any way to find out if the executeUpdate inserted the row or updated it?
-1
votes
0answers
23 views
JavaFX Dynamic TableView
I am trying to create a dynamic table view for an inventory table system with javaFX. I cannot get my query to display in table view. I have two methods.
The first is my SQLDriver class with a ...
1
vote
0answers
6 views
Slony replication stopped working
I inherited a 5 node postgres cluster running postgres 8.4 and slony 1.2.21. We are in the process of migrating the application to all new code and have not wanted to do very little maintenance on the ...
0
votes
1answer
16 views
postgres jsonb with issues
I am trying to build a query that will go into a table. Grab some data from within a jsonb column and then query against that data further.
WITH id_list AS (
SELECT
data #>> '{embeds, ...
1
vote
0answers
12 views
Django Redirects Causing Migration Error
I recently updated my local database to mirror production and now I am having migration issues. Trying to migrate an application called events:
./manage.py migrate events
NoMigrations: Application '&...
0
votes
1answer
17 views
How do you access a Django JSONField's keys using `django.models.F` or similar method during a query?
Is it possible to extract a sub-key from a JSONField field and annotate the Queryset with its value? I'm trying to extract the value within the query rather than post-processing in the Python code.
...
0
votes
1answer
26 views
Postgresql - INSERT INTO based on multiple SELECT
I intend to write a INSERT INTO request in Postgresql based on several SELECT but didn't succeed.
I have one table containing data I select (srctab), and another one where I insert data (dsttab).
Here ...
2
votes
3answers
18 views
Excluding joined records on column value?
For example, if I have Balls and Boxes, balls can be in many boxes, and boxes can be locked, how can I select the balls that are not in a locked box?
balls
id name
== ====
1 in neither
2 ...
0
votes
0answers
6 views
Docker SonarQube Qalityprofile
I have configured sonarqube:latest in Docker with Postgres DB. it is up and running. I am able to login. But, I am not able to see any default qualify profiles & languages.. if I tried to restore ...
0
votes
0answers
17 views
Very slow PostgreSQL query with existing code, restored DB
A little backstory: I was assigned a project (another company's product) to update data in a PostgreSQL database since it was out of date. I was given the code (exact same as what is on production) ...
2
votes
1answer
17 views
postgreSQL join and embed array of records
I have two tables. One is events and the other is people. They look like this:
events | data_type
--------------------+-----------
event_id | integer
start | ...
-1
votes
0answers
22 views
p:commandbutton not redirect after click and database has not new record spring config ok
Hellow. I have small application spring jsf jpa postgrresql. I configuring this good and proper with specification and advices form github, but after click commandbutton (primefaces) not redirect to ...
0
votes
1answer
30 views
Postgresql Query Results in Division by 0 After Use of Case to Check for 0
The following query is using a subquery to allow for a weighted value to be calculated. The problem I am receiving is a division by 0 error that occurs at random for true 0 value aggregates as well as ...
0
votes
1answer
24 views
Compare daily counts of orders from current month vs daily count from last moth
I want to compare the difference between this month daily orders count vs last month daily orders count and group them by day using postgresql sql query.
Example:
1st of nov count - 1st of oct count
-1
votes
1answer
14 views
Any example of source code about authentication with expressjs, postgresql?
Hello i'm trying to do an auth with expressjs, sequelize, postgresql i was trying to find a nice repo for improve my knowledge, but i cannot get one. Please thank you for your advice.
https://github....
0
votes
0answers
21 views
Android postgresql classnotfound
I am looking for a solution for the error ClassNotFoundException : org.postgresql.Driver I get when I try to use postgresql with my android app.
I copied the postgresql jar to my "libs" folder then I ...
3
votes
3answers
30 views
Arrays of custom type in PostgreSQL
I have a custom type in Postgres:
CREATE TYPE child AS
(id integer,
name text,
surname text,
age integer);
and table
CREATE TABLE parent
(
id integer NOT NULL,
name text NOT ...
-2
votes
0answers
17 views
PHP pg_connect causes return array to fail inside Wordpress site, getting no errors
EDIT: I drastically changed the content of this because I was able to better pinpoint my issue.
I have a script that runs successfully when called like php script.php in the command line. It queries ...
-1
votes
0answers
12 views
Access pybossa database trough terminal
the thing is tath i had pybossa installed with vagrant and juju, so when i've tried to access to posgresql prompt it says no postgresql installed which is not possible cause pybossa is already in ...
1
vote
1answer
20 views
How to return result from a sequelize query thats wrapped in a function
I am building a service that creates a unique url for a user.
It's supposed to do the following:
query database to see if the user already has the url and send it back
if user doesn't have ...
0
votes
2answers
24 views
PostgreSQL multiple CSV import and add filename to each column
I've got 200k csv files and I need to import them all to a single postgresql table. It's a list of parameters from various devices and each csv's file name contains device's serial number and I need ...
1
vote
0answers
51 views
cant find if a number is odd/even in a trigger
To reduce test time, I want reduce the number of rows process in my trigger. Should be easy but cant make it work.
original version doesnt have IF and works ok
this version with IF also work ok and ...
-2
votes
0answers
13 views
Use LocalDate or LocalDateTime with Springboot and Jpa
It`s possible to use LocalDate and LocalDateTime in my Entity(have any annotation or dependency)? with SpringBoot and Jpa(Postgresql)?
this is my pom:
<dependency>
<groupId&...
0
votes
0answers
30 views
Merge records in postgresql
I have this schema of batabase schema of batabase. A lot of clients that have many phone numbers are stored as separate clients because erlier I could not import a client with two or more phonenumbers
...
0
votes
0answers
21 views
How to pull YTD data of the previous N years based on today's date in Postgresql?
I need to pull a report based out of the CURRENT_DATE() and I need this report showing the data of previous N years too.
How should I write query in Postgresql?
Sample table: User- user_id|...
1
vote
1answer
30 views
Getting referenced tables in Postgres
I have a list of foreign keys. I'd like to find out the tables where these FK's point to and the actual key the point to.
I've got a list of FK's like so:
columnName0, columnName1, columnName2
...
0
votes
0answers
20 views
psql “role is not permitted to login” & “could not connect to server”
I cloned a project i did on cloud9 IDE on my computer. This project is on rails and use Heroku & postgresql.
I want to launch it from my computer, i did everything needed to launch the project ...