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
5 views
BTREE vs GIN vs GIST index
I'm using Postgres DB and I have a table called MyObjects with several varchar columns. The values will not be separated words (for example, urls, names etc..). I will be filtering according to these ...
0
votes
0answers
4 views
How to find average of Django ArrayField of integer
I have a following models:-
class companyData(models.Model):
companyId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
ratings = ArrayField(models.IntegerField(), ...
-3
votes
0answers
13 views
optimizing data combining from two different databases(mysql and postgres) on different servers
I have two databases
DB1 - postgres on server 1
DB2 - mysql on server2
getting userids from DB2 from user_address table
passing userid to DB1 to user table and fetch user details
iterate step 1) ...
0
votes
0answers
14 views
how to remove special characters like '(),comma' from field and display the value with separate line
I want to separate my data that is stored into field with comma and special character. And column name is res_scheduledjobs.sq_name_new1. So my record look like:
sq_name_new1
R&M(...
0
votes
1answer
12 views
Django unique together relationship with field and manytomany on self
I'm try create post with language and content, and relate it on other versions of same page, but I'm get stuck
class Page(models.Model):
content = models.TextField()
language = models....
1
vote
0answers
8 views
Connect PostgreSQL to HammerDB
As the title says, I want to connect PostgreSQL (I'm using the 9.6 x86 version) to HammerDB, an open source database load testing and benchmarking tool (I'm interested in the TPC-C Benchmark).
The ...
-1
votes
0answers
11 views
Sort each column of table
Hey I am new to sql/postgreSql. I was given a problem, I would like to have suggestions on how to do it. Below is the table I was given.
Student Maths Physics Chemistry
Joe 80 52 69
...
1
vote
1answer
12 views
PostgreSQL 9.5: Convert intervals INTO milliseconds
I have the following two dates which is in the form of varchar(50).
Date1: 2016-11-24 12:38:29.123
Date2: 2016-04-22 11:44:55
First date that is Date1 contains milliseconds and Date2 contains till ...
-3
votes
0answers
18 views
How to insert multiple radio button values into the postgresql database table into a single column as like the checkboxes [on hold]
How to insert multiple radio button values into the postgresql database table into a single column as like of the checkboxes?????
0
votes
1answer
13 views
how to put nested case-when condition in postgresql query
i want to write nested case when condition in query to store the value that will come from one case when condition and another case when condition into same new column.to get this kind of result i am ...
0
votes
0answers
30 views
Grouping datetime fields if speed data more than 60 km/h in a row
I'm trying to group date_created and device_id column if the speed data more than 60 km/h,
I keep trying for a weeks still don't find any solution.
Here my data:
id device_id date_created ...
0
votes
1answer
12 views
Delete related records before delete trigger postgresql
I need to make trigger, which will delete related rows in related table. Yes, I know about ON DELETE CASCADE, but the thing is I need to do it using trigger. I google it for several hours, but don't ...
0
votes
0answers
6 views
Not all named parameters have been set: [:timestamp::date]
Here is my code:
public static List<Bean> getDate(int id){
Session session = DatabaseSession.getInstance();
List<Bean> cmts = session.createSQLQuery("select datecommented::...
-2
votes
2answers
24 views
Return a single row but with additional columns in Postgresql
I want to create a function which returns a single row of a table, but some additional columns from other tables it can be joint with. How can I do that? Should I declare a new type? Or should I ...
0
votes
0answers
8 views
How to reset pgAdmin4 GUI?
I tried Ctrl++, Ctrl+-, then pgAdmin4 v1.1 (on Windows 10 Pro x64) error. Then, I tried re-install, but error still exist:
How to fix this error?
-4
votes
0answers
12 views
Inserting data into Datbase Pgsql [duplicate]
I have been trying to get the details fetched from an html form and pass it into the database. It seems like I am having an internal server error and I am not able to figure out the issue.
This is my ...
0
votes
0answers
12 views
Force short circuit on web2py DAL conditions
I am using web2py connected to a postgres database. I have the following query which takes a long time to run because of the second condition:
count = db((db.webhook_table.status==3) & (db....
0
votes
2answers
18 views
Handling Postgres Error Message To Perform Correct Query
I am using pg and node.js. When a user logs in using the auth0 widget I am passing the email it returns and checking my database to see if the user exist. If the user does not exist I am inserting ...
-1
votes
0answers
6 views
Node js enterprise application REST Api development
we want to develop a REST Api using Nodejs for an enterprise application.
Please guide us in the following areas as we are new to start in Nodejs
we decided to go with Nodejs Express Postgresql
1. How ...
1
vote
1answer
12 views
unix second into postgres timestamp using php pg_query_params
I want to insert a unix timestamp value into a postgres timestamp column, using the PHP pg_query_params method, but get stuck.
Here's the incomplete code:
$con = pg_connect(...);
$stmt = 'INSERT ...
1
vote
1answer
11 views
trigger function in postgresSQL
im trying to make a trigger function that will check if on insert/update of a record of event date the information is valid:
create or replace function trigf() returns trigger as $$
declare bad_date ...
1
vote
1answer
37 views
Why is table-swapping in Postgres so verbose?
I'd like to backfill a column of a large (20M rows), frequently-read but rarely-written table. From various articles and questions on SO, it seems like the best way to do this is create a table with ...
0
votes
2answers
44 views
Count groups of NULL values - partition or window?
n | g
---------
1 | 1
2 | NULL
3 | 1
4 | 1
5 | 1
6 | 1
7 | NULL
8 | NULL
9 | NULL
10 | 1
11 | 1
12 | 1
13 | 1
14 | 1
15 | 1
16 | 1
17 | NULL
18 | 1
19 | 1
20 | 1
21 | ...
0
votes
1answer
18 views
How to import or sync data to Neo4?
I have a REST API around a PostgreSQL database, the API was built using the Django REST Framework (python). I have access to the PostgreSQL database and the API, but I'm not allowed to modify the ...
1
vote
0answers
17 views
cakePHP find() returns field name instead of just the column values
I'm trying to retrieve data from my database using the find() method.
But when I use find('all') it returns the column value and column name together, like this: { "date_1": "2015-25-12"}, of course,...
0
votes
1answer
20 views
Can web2py tasks(scheduler) have a race condition with web2py actions?
I am running a web2py application which has a function that is called by a webhook from an external source. That function schedules a task and puts data from the webhook into my db. The task it ...
3
votes
1answer
25 views
Show Heroku database information in Django
Is there a way to display a database's information in a Django view?
For example, I know in the Heroku cli you can do heroku pg:info -a your_app to view the database's table count, row count, type, ...
-2
votes
0answers
9 views
metasploit connecting to database
A database appears to be already configured, skipping initialization
[-] Failed to connect to the database: could not connect to server: Connection refused
Is the server running on host "localhost"...
0
votes
0answers
14 views
Postgres function with query returns different value for row count ; as compared to query run by itself on postgres console
Postgres function with query 'A' returns different value for row count ;
as compared to query 'A' run by itself on postgres console.
Please check the resultset values for both the below code blocks.
...
0
votes
2answers
18 views
PostgreSql - Declare integer variable
I'm trying to declare integer variable with default value 0 in postgresql sql script:
DECLARE user_id integer;
but it returns exception:
ERROR: syntax error at or near "integer"
I'm not sure how ...
0
votes
0answers
37 views
FOR LOOP not going through all rows
I have written the below function:
CREATE OR REPLACE FUNCTION ciro7(nClient client.cli_num%type, year double precision)
RETURNS NUMERIC AS $$
DECLARE
requested request.units%type;
nProd request....
0
votes
0answers
14 views
Trying to optimize a subquery in Postgres sql
I've been working on this query for a while now and I've finally gotten it to produce the results I want. However, it is taking a long time to run. I was hoping there were some optimization tips to ...
0
votes
1answer
8 views
Grant read-only permissions
I want to assigned basic read-only permissions for a PostgreSQL database role that must access from an Application server like Glassfish.
1
vote
1answer
48 views
How to generate SQL from Request?
Currently I use next approach for retreiving data according to request:
/**
* @QueryParam(name="filters", nullable=true, map=true, description="Filter by fields. Must be an array ie. &filters[id]...
0
votes
0answers
15 views
Schema “tmp” doesn't exist inside SQL generated dump file?
I'm trying to import my SQL dump to psql but there is a problem (as mentioned in the title). I'm not to sure why this happens, and what to do against it.
This is the command I am using
psql -U ...
0
votes
0answers
10 views
aiohttp.web + aiopg: random “cursor.execute() called while another coroutine is already waiting for incoming data” under load
I have a trivial aiohttp.web application that executes SQL requests via aiopg. It's as simple as:
import aiohttp.web
from aiopg.sa import create_engine
app = aiohttp.web.Application()
async def ...
0
votes
1answer
15 views
Psycopg2 issue inserting values into an existing table in the database
I am having a hard time understanding why psycopg2 has a problem with the word 'user'. I am trying to insert values into a table called user with the columns user_id, name, password. I am getting a ...
1
vote
3answers
42 views
offset count(*) / N columns
I do some job in few machines.
Need divide rows into equal parts for each machine.
Query with all conditions performed long time.
Is it possible to do this without additional request count(*), in one ...
3
votes
3answers
50 views
How can I return rows that meet a specific sequence of events?
I am trying to pull records for UserIDs that meet a certain sequence of events. If a user has a JOIN, then a subsequent CANCEL, and then a subsequent JOIN, I want to return them in the result set. I ...
0
votes
1answer
34 views
How to delete data without losing them
There is two tables:
STUDENTS (STUDENT_ID, GROUP_ID)
GROUPS (GROUP_ID, NAME)
I need to write query that delete students from specify group (suppose there is group with 'target_id') without losing ...
0
votes
0answers
15 views
How to connect to remote PostgreSQL server with ssh tunnel through C#
I try to connect to remote PostgreSQL server i have Host name,User Name Password for connecting to database besides i have ssh parameters SSH host name,SSH port,SSH user name and SSH password.
I ...
0
votes
0answers
15 views
optimize migration of table from csv to pg with self join update
I have a CSV of size 1.5GB containing around 11000000 records and I am populating that data to Postgres table
What I have tried so far is:
set local work_mem = '4000MB';
copy truck_dispatch_logs(
...
0
votes
3answers
53 views
how to perform operations in queries programatically?
How to do the operation w_balance = w_balance + amount in the query String? One way is to perform the operation outside the Query String. But is there a way to do that directly? Here, amount is the ...
0
votes
0answers
26 views
How do I get the “id” after INSERT into a postgres database with Python?
I am doing an INSERT into a postgres DB, which has an auto increment field called id.
How do I get the value of id after doing the insert in Python? There are good references on this site to this ...
0
votes
1answer
13 views
Creating Postgis Polygon using ST_ConcaveHull from Geometry Points
I have a postgis 2.2 table with 20 columns of type geometry(Point,4326)
I'd like to generate a polygon which covers the outer boundary of the points - it seems like ST_ConcaveHull is a good option, ...
0
votes
0answers
11 views
Bugzilla - Table already exists: bz_schema at Bugzilla/DB/Schema.pm
I'm having some trouble installing bugzilla on a postgreSQL DB. on a centOS server.
When running the checksetup.pl file the output end with :
Reading ./localconfig...
Checking for DBD-...
0
votes
0answers
11 views
HAProxy + pgbouncer server closed the connection unexpectedly
I have an architecture of haproxy on web server which is routing to slave servers, where I have pgbouncer over postgre.
HAPoxy config:
global
log 127.0.0.1 local1 debug
user haproxy
group ...
0
votes
0answers
19 views
How to show row and column crosstab query in PostgreSQL?
accountName ProductsTypes ProductPrice Total
bell account Food Menu Category 29634 40634
bell account SleepingRooms 9000 40634
bell account ...
0
votes
1answer
10 views
Mapping postgreSQL inetger[] data type to Grails
In my postgreSQL DB i have a field with the data type int[] trying to mapp this to a Grails domain class column Integer[] the application fails to start:
org.hibernate.type.SerializationException: ...
0
votes
1answer
24 views
Postgresql alter table -> add column + values
I need to alter a table in my DB. What I want is to ad a column with type integer[] and add values to this column directly from another query which result is 4 id numbers.
What I got currently:
...