postgresql

PL/PostgreSQL how to convert a variable into a table name

心不动则不痛 提交于 2021-01-07 02:51:18
问题 So I have a function in PostgreSQL that dynamically selects columns from a dynamic table. I got this solution from this post and it works great other than one thing. This is inside of a file that is connected to a Node server, and so the $1 and $2 in the second SELECT * FROM represent values passed from there. The issue right now is that I am getting a syntax error that I don't understand (I am newer to SQL so that may be why). $2 represents the name of the table to be selected from as a

A bad issue with kafka and Spark Streaming on Python

拟墨画扇 提交于 2021-01-07 02:45:47
问题 N.B. This is NOT the same issue that I had in my first post on this site, however it is the same project. I'm ingesting some files into PostgreSQL from kafka using spark streaming. These are my steps for the project: 1- Creating a script for the kafka producer (done, it works fine) 2- Creating a python script that reads files from kafka producer 3- Sending files to PostgreSQL For the connection between python and postgreSQL I use psycopg2. I am also using python 3 and java jdk1.8.0_261 and

A bad issue with kafka and Spark Streaming on Python

别等时光非礼了梦想. 提交于 2021-01-07 02:42:46
问题 N.B. This is NOT the same issue that I had in my first post on this site, however it is the same project. I'm ingesting some files into PostgreSQL from kafka using spark streaming. These are my steps for the project: 1- Creating a script for the kafka producer (done, it works fine) 2- Creating a python script that reads files from kafka producer 3- Sending files to PostgreSQL For the connection between python and postgreSQL I use psycopg2. I am also using python 3 and java jdk1.8.0_261 and

A bad issue with kafka and Spark Streaming on Python

戏子无情 提交于 2021-01-07 02:42:17
问题 N.B. This is NOT the same issue that I had in my first post on this site, however it is the same project. I'm ingesting some files into PostgreSQL from kafka using spark streaming. These are my steps for the project: 1- Creating a script for the kafka producer (done, it works fine) 2- Creating a python script that reads files from kafka producer 3- Sending files to PostgreSQL For the connection between python and postgreSQL I use psycopg2. I am also using python 3 and java jdk1.8.0_261 and

Chained join not filtering as expected

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-07 01:53:08
问题 I have a related question here: Generate month data series with null months included? When I posted I omitted the second join thinking it was trivial and not impact my question - I was wrong there. SELECT TO_CHAR(activity_tasks.start_date, 'MON') AS month, EXTRACT(MONTH FROM activity_tasks.start_date) AS month_num, SUM(cost_planned) FILTER (WHERE activity_tasks.aasm_state IN ('open', 'planned' ) ) AS planned, SUM(cost_actual) FILTER (WHERE activity_tasks.aasm_state IN ('closed' ) ) AS actual

Chained join not filtering as expected

怎甘沉沦 提交于 2021-01-07 01:46:51
问题 I have a related question here: Generate month data series with null months included? When I posted I omitted the second join thinking it was trivial and not impact my question - I was wrong there. SELECT TO_CHAR(activity_tasks.start_date, 'MON') AS month, EXTRACT(MONTH FROM activity_tasks.start_date) AS month_num, SUM(cost_planned) FILTER (WHERE activity_tasks.aasm_state IN ('open', 'planned' ) ) AS planned, SUM(cost_actual) FILTER (WHERE activity_tasks.aasm_state IN ('closed' ) ) AS actual

Chained join not filtering as expected

有些话、适合烂在心里 提交于 2021-01-07 01:45:18
问题 I have a related question here: Generate month data series with null months included? When I posted I omitted the second join thinking it was trivial and not impact my question - I was wrong there. SELECT TO_CHAR(activity_tasks.start_date, 'MON') AS month, EXTRACT(MONTH FROM activity_tasks.start_date) AS month_num, SUM(cost_planned) FILTER (WHERE activity_tasks.aasm_state IN ('open', 'planned' ) ) AS planned, SUM(cost_actual) FILTER (WHERE activity_tasks.aasm_state IN ('closed' ) ) AS actual

Chained join not filtering as expected

强颜欢笑 提交于 2021-01-07 01:44:39
问题 I have a related question here: Generate month data series with null months included? When I posted I omitted the second join thinking it was trivial and not impact my question - I was wrong there. SELECT TO_CHAR(activity_tasks.start_date, 'MON') AS month, EXTRACT(MONTH FROM activity_tasks.start_date) AS month_num, SUM(cost_planned) FILTER (WHERE activity_tasks.aasm_state IN ('open', 'planned' ) ) AS planned, SUM(cost_actual) FILTER (WHERE activity_tasks.aasm_state IN ('closed' ) ) AS actual

Multiple queries in a .map function

孤者浪人 提交于 2021-01-07 01:36:16
问题 const returnPostData = async (req, res, initialPostsQueryArray) => { try{ const promises = initialPostsQueryArray.map( async (post) => { let voteCount = 0; let voted = false; let liked = false; let userHandle; let userImageUrl; let votingOptionsDictionary; let userVoteOption; voteCount = sumValues(post.voting_options); pool.query('SELECT userhandle, image_url FROM users WHERE id = $1 ', [post.user_id], (error, results) => { if (error) { console.log(error); return res.json({'Error': error

Multiple queries in a .map function

大憨熊 提交于 2021-01-07 01:33:15
问题 const returnPostData = async (req, res, initialPostsQueryArray) => { try{ const promises = initialPostsQueryArray.map( async (post) => { let voteCount = 0; let voted = false; let liked = false; let userHandle; let userImageUrl; let votingOptionsDictionary; let userVoteOption; voteCount = sumValues(post.voting_options); pool.query('SELECT userhandle, image_url FROM users WHERE id = $1 ', [post.user_id], (error, results) => { if (error) { console.log(error); return res.json({'Error': error