postgresql

Postgres JSONb to XML with tag_name and tag_value

和自甴很熟 提交于 2021-02-08 07:23:49
问题 I am new to Postgres XML functions. I have a table as below: id (VARCHAR) | field1 (text) | attributes (jsonb) --------------+---------------+---------------------------------- 123 | a | {"age": "1", "place": "TX"} 456 | b | {"age": "2", "name": "abcdef"} 789 | | 098 | c | {"name": "gefd"} Would like to convert it to : <Company id="123" field="a"> <CompanyTag tagName="age" tagValue="1"/> <CompanyTag tagName="place" tagValue="TX"/> </Company> <Company id="456" field="b"> <CompanyTag tagName=

How I search datasets by multiple tags using CKAN API?

房东的猫 提交于 2021-02-08 07:18:18
问题 I'm using CKAN portal with API version "ckan_version": "2.5.x" I have few tags and I need to send using API these tags and I need to return a list of matching entries of packages or resources. Is possible to use do use package_search endpoint to search for packages with all given tags, but it works as "AND" operator, and that I need is a "OR" operator. e.g.: http://demo.ckan.org/api/3/action/package_search?fq=tags:contabilidade-social <-- return 11 packages that contains 'contabilidade-social

How I search datasets by multiple tags using CKAN API?

烂漫一生 提交于 2021-02-08 07:16:41
问题 I'm using CKAN portal with API version "ckan_version": "2.5.x" I have few tags and I need to send using API these tags and I need to return a list of matching entries of packages or resources. Is possible to use do use package_search endpoint to search for packages with all given tags, but it works as "AND" operator, and that I need is a "OR" operator. e.g.: http://demo.ckan.org/api/3/action/package_search?fq=tags:contabilidade-social <-- return 11 packages that contains 'contabilidade-social

Calculating follower growth over time for each influencer

血红的双手。 提交于 2021-02-08 07:01:47
问题 I have a table with influencers and their follower counter for each day: influencer_id | date | followers 1 | 2020-05-29 | 7361 1 | 2020-05-28 | 7234 ... 2 | 2020-05-29 | 82 2 | 2020-05-28 | 85 ... 3 | 2020-05-29 | 3434 3 | 2020-05-28 | 2988 3 | 2020-05-27 | 2765 ... Let's say I want to calculate how many followers each individual influencer has gained in the last 7 days and get the following table: influencer_id | growth 1 | <num followers last day - num followers first day> 2 | " 3 | " As a

Calculating follower growth over time for each influencer

社会主义新天地 提交于 2021-02-08 07:01:07
问题 I have a table with influencers and their follower counter for each day: influencer_id | date | followers 1 | 2020-05-29 | 7361 1 | 2020-05-28 | 7234 ... 2 | 2020-05-29 | 82 2 | 2020-05-28 | 85 ... 3 | 2020-05-29 | 3434 3 | 2020-05-28 | 2988 3 | 2020-05-27 | 2765 ... Let's say I want to calculate how many followers each individual influencer has gained in the last 7 days and get the following table: influencer_id | growth 1 | <num followers last day - num followers first day> 2 | " 3 | " As a

@Tailable(spring-data-reactive-mongodb) equivalent in spring-data-r2dbc

大城市里の小女人 提交于 2021-02-08 06:43:28
问题 I am trying my hands on spring-data-r2dbc. I am try this on Postgresql. I have tried spring-data-mongodb-reactive before. I couldn't help but to compare both. I see that Query Derivation is not yet supported. But I was wondering if there is an equivalent for @Tailable . This way I would be notified of the database changes in real time. Ca anyone share any code samples with respect to this. I understand that the underlying database should support this. I believe Postgresql does support this

Error while configuring postgressql for django

一世执手 提交于 2021-02-08 06:40:11
问题 I have implemented full text search in my django app using postgresql. But, when I press the search button, I get an error: ProgrammingError at /blog/search/ function similarity(character varying, unknown) does not exist LINE 1: SELECT COUNT(*) FROM (SELECT SIMILARITY("blog_post"."title",... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. I don't know where the error is, so if you need any files, I will edit this question. Please help

Error while configuring postgressql for django

时间秒杀一切 提交于 2021-02-08 06:39:09
问题 I have implemented full text search in my django app using postgresql. But, when I press the search button, I get an error: ProgrammingError at /blog/search/ function similarity(character varying, unknown) does not exist LINE 1: SELECT COUNT(*) FROM (SELECT SIMILARITY("blog_post"."title",... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. I don't know where the error is, so if you need any files, I will edit this question. Please help

How to do username case insensitive in login form?

本小妞迷上赌 提交于 2021-02-08 06:37:33
问题 I'm using the login form from Symfony, but I can't login, if the entered username is 'FOO' and in the DB is stored 'foo'. I'm using Postgres. It means the username-field is case sensitive. What can I do? 回答1: This depends mainly on your Database-Server. MySQL is case insensitive, PostgreSQL is case sensitive. But you can write query Like this $this->createQueryBuilder('user') ->where('LOWER(user.username) = :username') ->setParameter('username', strtolower($username)) ->getQuery() ->getResult

postgreSQL Fibonacci Sequence - Query has no destination for result data

泄露秘密 提交于 2021-02-08 06:23:33
问题 So I wrote a Fibonacci sequence function like this: CREATE OR REPLACE FUNCTION fibonacci (lastN INTEGER) RETURNS int AS $$ BEGIN WITH RECURSIVE t(a, b) AS ( VALUES(0,1) UNION ALL SELECT GREATEST(a, b), a + b AS a from t WHERE b < $1 ) SELECT a FROM t; END; $$ LANGUAGE plpgsql; But when I called: SELECT * FROM fibonacci(20); the console shows: ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function