postgresql

Spring managed bean injection in class implementing RowMapper

百般思念 提交于 2021-01-27 19:05:23
问题 I have a class BusinessRowMapper that implements RowMapper to convert PostGres JSONB object to Java object. BusinessRowMapper implements RowMapper<PersonDetails> it overrides mapRow public class BusinessRowMapper implements RowMapper<PersonDetails> { private PersonUtility utils; public BusinessRowMapper(PersonUtility utils) { super(); this.utils = utils; } public PersonDetails mapRow(final ResultSet rs, final int rowNum) throws SQLException { PersonDetails personDetail = utils

PostgreSQL Connection Timed Out OperationalError on Django and new server

一曲冷凌霜 提交于 2021-01-27 19:01:03
问题 After my server got compromised, I've had to migrate to a new droplet - both on DigitalOcean, Debian Jessie, so I shouldn't have the Heroku issues that a lot of the similar questions seem to cover. I copied the database over using pg_dump, and it seems intact. PostgreSQL is installed, and running, but whenever I try to utilise the database from the Django ORM, I get the error - OperationalError: could not connect to server: Connection timed out Is the server running on host "localhost" (127.0

postgresql Remove trailing zeroes

落爺英雄遲暮 提交于 2021-01-27 18:51:21
问题 I have a query which is proving to be cumbersome for me. I want to remove the trailing zeroes from the result. Remove trailing zeros from decimal in SQL Server Remove trailing zeroes using sql select concat(100 * round(cast(count(ft.*) filter (where "Realtor_Sale" = 'Yes') as numeric(12,5)) / cast(count(ft.*) as numeric(12,5)),3),'%') as "Realtor Sales" Result I am getting is: 84.800% --------------> I want 84.8%. I tried doing this as well: select concat(100 * round(cast(cast(count(ft.*)

SELECT fixed number of rows by evenly skipping rows

 ̄綄美尐妖づ 提交于 2021-01-27 18:41:06
问题 I am trying to write a query which returns an arbitrary sized representative sample of data. I would like to do this by only selecting n th rows where n is such that the entire result set is as close as possible to an arbitrary size. I want this to work in cases where the result set would normally be less than the arbitrary size. In such a case, the entire result set should be returned. I found this question which shows how to select every n th row. Here is what I have so far: SELECT * FROM (

PostgreSQL query with dynamic number of columns

不打扰是莪最后的温柔 提交于 2021-01-27 18:29:31
问题 I am trying to find a method to return a record set with a dynamic number of columns. I can write one query that will produce the list of column names I need as such: SELECT DISTINCT name FROM tests WHERE group = 'basic'; This will return a short list like 'poke', 'prod', 'hit', 'drop', etc. Then I want a table produced showing a series of tests where each of those tests were run. Every morning we look at what the developers have been doing and poke and prod at it so each test will be run for

Create int8[] array in PostgreSQL C function

纵然是瞬间 提交于 2021-01-27 17:48:10
问题 I'm trying to get a feel for processing arrays in C for PG. There are examples of reading existing arrays, but I can't find one on how to create and set a new one. This is what I've got so far. I think my intent is clear: PG_FUNCTION_INFO_V1(makearray); PGMODULEEXPORT Datum makearray(PG_FUNCTION_ARGS) { long a = PG_GETARG_INT32(0); ArrayType* result = new_intArrayType(a); for (long i = 0; i < a; i++) { result[i] = DatumSetInt32(i); } PG_RETURN_ARRAYTYPE_P(result); } How do I set the value for

How to compile Qt 5.8 statically with PostgreSQL plugin in VS2015

北战南征 提交于 2021-01-27 17:39:55
问题 Can anybody who may have any idea compiling Qt 5.8 Open Source statically with PostgreSQL support on Windows. I tried all the options known to me including the below. I'm using qt 5.8 sources on Windows 10 x64. configure -opensource -confirm-license -debug-and-release -static -platform win32-msvc2015 -nomake examples -nomake tests -sql-psql PSQL_LIBS="C:\PSQL\9.6\lib\libpq.lib" -I C:\PSQL\9.6\include\libpq -I C:\PSQL\9.6\include -L C:\PSQL\9.6\lib\libpq.lib After running the config above, I

Postgres can't listen to a specific IP address

て烟熏妆下的殇ゞ 提交于 2021-01-27 17:33:14
问题 I'm trying to block access to my PostgreSQL and allow access only to Localhost and my machine external IP, something like: "172.211.xx.xx". This IP is provided by my ISP (Internet Service Provider). In postgresql.conf I set the following line: listen_addresses = '179.211.xx.xx' But I can't connect to the database from my machine. I get "Server don't listen". If I change to: listen_addresses = '*' everything works, but I can't do it. I need to enable access only to this IP. This is a security

PostgreSQL/PostGIS - PQexecParams - wrong element type

折月煮酒 提交于 2021-01-27 17:26:58
问题 I have this code. const char * q = "INSERT INTO test_raster (raw_data) VALUES (ST_SetValues(ST_AddBand(ST_MakeEmptyRaster(2, 2, -180, -90, 180, -90, 0, 0, 4326), 1, '8BUI', 0, 0), 1, 1, 1, $1::double precision[][]))"; double tmp[2][2] = { {0, 125}, {45, 255} }; const char *values[1] = { (char *)&tmp }; int lengths[1] = { 4*sizeof(double) }; int binary[1] = { 1 }; PGresult *rs = PQexecParams(psql, q, 1, NULL, values, lengths, binary, 0); auto stat = PQresultStatus(rs); printf("%s",

Use JOOQ to do a delete specifying multiple columns in a “not in” clause

╄→гoц情女王★ 提交于 2021-01-27 17:17:32
问题 I want to bring a postgres database table in sync with a list of Jooq Records. I have a table with a composite primary key and three other values in each row table(k1, k2, v1, v2, v3) For example, the data might be Last, First, Age, Weight, Height Smith, Joe, 21, 75, 160 Jones, Pete, 23, 80, 180 (excuse the poor form of using names as primary keys....) I also have a list of Jooq Records for that table in my java code. Let's say that there's two java records [ <Smith, Joe, 21, 75, 180>,