Data dodania Pytanie
2017-01-05 05:01 Django inspectdb skips tables with constraints »
I read a few topics on this, but none really seemed to offer a solution in inspectdb, or an alternative, that permits Django to make models for an exi...
(0) odpowiedzi
2017-01-04 18:01 Sorting in Rails: SQLite vs PostgreSQL »
When I order by a column (id type INT) in Rails 5 with sqlite as the development db, it sorts as expected (1,2,3,4...) but the same thing on my produc...
(1) odpowiedzi
2017-01-04 15:01 How to COPY CSV as JSON fields »
Is there a way to COPY the CSV file data directly into a JSON or JSONb array? Example: CREATE TABLE mytable ( id serial PRIMARY KEY, info jS...
(1) odpowiedzi
2017-01-04 14:01 How to reassign all privileges to another role in PostgreSQL? »
​On an existing PostgreSQL server let say that I have two users "Alice" & "Bob" and I want to clean up my policy because they actually have the ...
(0) odpowiedzi
2017-01-04 11:01 Rails TimeZone issue - Group query »
I have my server in NYC and the data in PostgreSQL is stored in UTC but all my data on the presentational layer is to be shown in IST I have the foll...
(0) odpowiedzi
2017-01-04 07:01 How to sum all columns value of a table and display the total in new row by using Postgresql »
I am using normal select query to display all rows SELECT type, debit, credit, (debit-credit) as balance from bank_cash_registers ...
(2) odpowiedzi
2017-01-03 23:01 Database structure and queries for a Twitter-like posts timeline »
I'm posting this question with a Django tag, because I'm working in this environment, but it's actually more or a generic question: I'd like to show s...
(3) odpowiedzi
2017-01-03 19:01 Efficient SQL table joining or query in POSTGRES ? How and what to do? »
I have the following tables table 1 ID1 YEAR1 1 1980 2 1964 3 1910 table 2 ID2 YEAR2 VALUE 1 2000 A ...
(4) odpowiedzi
2017-01-03 13:01 MySQL vs PostgreSQL JSON search features »
I have been searching for a blog post or a feature matrix which compares MySQL and PostgreSQL by their JSON capabilities. I found a good feature matri...
(1) odpowiedzi
2017-01-03 08:01 How to install Secondary Postgres Plus server on same Linux machine »
I already have a primary Postgres server installed in /opt/PostgresPlus . Now i'm trying to install a secondary server on same linux machine using ppa...
(0) odpowiedzi
2017-01-02 18:01 How to efficiently store a two-dimensional array with different File types in a Django Model (PostgresSQL) »
I will like to store in a Django model the variations on the price of some houses for a date. For example: House.objects.create(name='house1', prices...
(0) odpowiedzi
2017-01-02 18:01 Run SQL statements in PL/pgSQL only if a row doesn't exist »
I want to do something like this in a PL/pgSQL function in Postgres 9.6: INSERT INTO table1 (id, value) VALUES (1, 'a') ON CONFLICT DO NOTHING; --- I...
(4) odpowiedzi
2017-01-02 05:01 pg_stat_activity doesn't update within a procedure or transaction »
I query pg_stat_activity but the contents seem to stay the same after the first time I query it within a plpgsql function body, SERIALIZABLE or REPEAT...
(1) odpowiedzi
2017-01-01 13:01 Postgres: getting the maximum and minimum values, and timestamps they occur »
I'm running Postgres 9.2, and have a table of temperatures and timestamps, one timestamp per minute in millisecond epoch time: weather=# \d weather_d...
(2) odpowiedzi
2017-01-01 10:01 insert array into postgresql map prepared statement »
I have this code : require 'pg' a = ["bla","foo","bar","test","wow"] begin con = PG.connect :dbname => 'base', :user => 'thatsme' a.map do |...
(2) odpowiedzi
2017-01-01 10:01 Find and update a collection in JSONB »
I have a Rails 5.0 app with a JSONB column called data, which contains an array of hashes: [ {'event': 'web_session', 'user_id': 1, 'count': 13},...
(0) odpowiedzi
2017-01-01 03:01 How to deploy a multi-tenant django app to AWS? »
I have an Django+Postgres app that has a multi-tenant structure and I don't have prior experience deploying this type of app to AWS. I have followed t...
(1) odpowiedzi
2016-12-31 19:12 Rails 5 SQL Injection »
I've read about this for some time now on various SO threads, guides, etc... but all the answers are conflicting and contradictory. It seems there's ...
(1) odpowiedzi
2016-12-31 16:12 Computed id from string as database key »
I have a XML-Interface with entries that i need to parse and then insert into a database. The entries have all the required information but i want to ...
(1) odpowiedzi
2016-12-31 15:12 SQL Error - Column does not exist (in SELECT as) »
I am joining two tables: breeds + breed_characteristics (bc) But I'm getting the following error: PG::UndefinedColumn: ERROR: column "val" doe...
(2) odpowiedzi
2016-12-30 20:12 Count equal, consecutive values in an ordered rowset »
I have a table with two columns like: CREATE TABLE actions ( action_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "action" text NOT NULL ); ...
(4) odpowiedzi
2016-12-30 20:12 Optimal Way to Avoid Duplicate SubQuery in SQL »
I have a simple two column table. For example's sake we can use the following to build the data: CREATE TABLE Duplicates (assignmentid varchar(5), ...
(2) odpowiedzi
2016-12-30 09:12 OPENQUERY throwing "Out of memory" error: limit rows until all are loaded »
In SQL Server 2016 I have a stored procedure. In this SP I want to get all data from a view from a linked server (PostgreSQL) by using the following s...
(1) odpowiedzi
2016-12-30 08:12 Getting the list of Objects and the corresponding value in Postgres (JSON data) »
I have the following JSON data which has an array of Objects PRODUCTION -> KBM -> (array of Objects) What I am looking for is to get all the values f...
(1) odpowiedzi
2016-12-29 12:12 SQL select every xth row based on total number »
I have a table with gps data: lat, lon, timestamp My queries select by a timestamp window: SELECT * FROM gps WHERE timesamp >= '2016-12-12T02:0...
(2) odpowiedzi
2016-12-29 10:12 How can I traverse a tree bottom-up to calculate a (weighted) average of node values in PostgreSQL? »
The typical example for e.g. summing a whole tree in PostgreSQL is using WITH RECURSIVE (Common Table Expressions). However, these examples typically ...
(1) odpowiedzi
2016-12-29 08:12 In postgresql how to change the value in jsonb type cloumn? »
Now I want to use postgresql function to change the jsonb type cloumn's value,now I have a function achieve the type json CREATE OR REPLACE FUNCTION...
(1) odpowiedzi
2016-12-29 05:12 Select random from SQL table which evenly distributes across a column's different values »
I have a table USERS which holds demographic information. For brevity, lets say one of the columns AGE can have one of five values (16, 17, 18, 19, 20...
(2) odpowiedzi
2016-12-28 19:12 Using variables in a PL/pgSQL function »
Postgres PL/pgSQL docs say: For any SQL command that does not return rows, for example INSERT without a RETURNING clause, you can execute the co...
(2) odpowiedzi
2016-12-28 16:12 SQL Server's SET NOCOUNT ON Postgresql equivalent »
I've to help migrating a SQL Server 2008 database to a PostgreSQL 9.4.10 one. The original querys have SET NOCOUNT ON and SET NOCOUNT OFF several time...
(0) odpowiedzi
2016-12-28 16:12 Create criteria statement, get the result and the row count with one query »
I'm trying to fetch results and also the row count inside a single query for pagination. This is what I got so far: public List<User> getUser...
(0) odpowiedzi
2016-12-28 13:12 Rails: How to show items only if creator is unique? »
I have many users and each user has multiple projects. Now, I want to get only one item per user. @projects = Project.all.where(user_id is unique) ...
(2) odpowiedzi
2016-12-28 05:12 New to ruby, hard time understanding combined ruby/sql syntax (that is also hard to google) »
I would appreciate some pointers to how to interpret some probably trivial syntax in an sql statement within a ruby method Basically, the function is...
(2) odpowiedzi
2016-12-28 02:12 How to loop through jsonb array of objects to get values of keys within objects Postgres »
I am using Postges 9.4 and I have a table that has a jsonb field as an array of objects. Here is a sample field: [{"pk": 224, "arbitrary_value": 50,...
(1) odpowiedzi
2016-12-27 17:12 query that shows if the tables might need analyze and vacuum »
i have this doubt I loking for a query that returns if my tables from given schema need analyze and vacuum before wraparound wich can not happen, so ...
(0) odpowiedzi