postgresql text search in json column with knex.js - postgresql

I'm using the postgresql in node application with knex.js
I want to search for a value that is present in the JSON column
I'm able to do the same in posgresql but unable to find any equivalant in knex.js
select * from <table_name> where <json_column_name>::text like '%search_value%'

Related

No tables in Grafana builder for PostgreSQL

I have setup Grafana and PostgreSQL.
I have connect Grafana to Postgresql, and I can run a query if I select "code" in the Explore and pick the Postgresql data source.
But if I use the builder, and would select the table from the table dropdown it mention "no options found"
Why can't I pick the table and columns in the builder?
I did set my search path in postgresql and now I can see the table:
ALTER ROLE grafanareader set search_path = "my schema";

Inserting value with multiple lines are different in pyspark and simple sql query via jdbc (hive)

If you run this sql query (using jdbc, hive server):
--create table test.testing (a string) stored as ORC;
insert into test.testing values ("line1\nline2");
I want to get 1 record but I'll get 2 reconds in tables.
If you run this sql query but using pyspark:
spark.sql("""insert into test.testing values ('pysparkline1\npysparkline2')""")
I'll get 1 record in table
How I can add multiple row data in table column using "insert ... values (...)" statement to manage this problem via jdbc?
P.S. Query type "INSERT... from SELECT" is not suitable and i can not change line delimeter in create query

How can I get a tablename of a PostgreSQL cursor?

I know that in Oracle we can do something like select * from TABLE(DBMS_XPLAN.DISPLAY_CURSOR('$$SQL_ID')). But there is no sql id field in pg_cursors catalog. We have only declaration text. And in general it's not Oracle. So, are there any ways to get a table name of an opened cursor in postgreSQL, besides parsing a sql statement(pg_cursors.statement)?

On Google Data Studio, using PostgreSQL data, how do I "SELECT * ..." but for camelCase columns?

On Google Data Studio, I cannot create a chart from Postgres data if table columns are in camelCase. I have data in PostgreSQL where I want to get charts from. Integrating it as a data source works fine. Now, I have a problem when creating a chart.
After creating a chart and selecting a data source, I try to add a column, which results in this error:
Error with SQL statement: ERROR: column "columnname" does not exist Hint: Perhaps you meant to reference the column "table.columnName". Position: 8
It just so happens that all my columns are in camelCase. Is there no way around this? Surely this is a basic question that has been resolved.
When connecting to your data source, try using 'Custom query' instead of selecting a table from your database. Then manually write your SQL query where you cast your camel case column names to lower case using sql alias. Worked for me.
example:
SELECT
"camelCaseColA" as cola,
"camelCaseColB" as colb,
"camelCaseColC" as colc
FROM
tableName as table

How to show contents in a postgresql table

I logged into my postgresql database in a cloud server, and I know that \d is used for showing all tables in my database, and \d mytablename is used for showing all columns in the table.
However, can anyone tell me how to show the contents of each column in the table?
I have tried to use SELECT * FROM mytablename, but it does not make any difference.