Forum
No internet connection
  1. Home
  2. Training and Certification

Send data to postgresql[WISE-PaaS/EnSaaS DB Service]

By tan sou wei @souwei
    2020-10-06 02:57:00.983Z

    HI there, i have done using node-fetch to get data from api url, however i am having problem in sending data to postgresql, i am thinking using node-postgres to send data, but i not so familiar, can you suggest any other ways? Thank you.

    Solved in post #7, click to view
    • 9 replies
    1. M
      @marc_lin
        2020-10-06 03:25:33.951Z

        Hi @souwei,

        For sending data to the PostgresSQL, please refer to the source code mqtt-postgres-k8s in the level 2 training course.
        https://github.com/WISE-PaaS/mqtt-postgres-k8s
        https://training.wise-paas.advantech.com/zh-TW/Level-II/content/DB-Source_Code_Inspection

        Thank you~

        1. In reply tomarc_lin:
          Stan sou wei @souwei
            2020-10-06 09:37:23.819Z

            hi sir, i have tried with the method you gave, with the credential key also, i able to get the data view using ingress url, but the table is missing when i want to make dashboard. i am using the code to create table.
            module.exports.sqlCreatTable = CREATE SCHEMA "final_projects"; ALTER SCHEMA "final_projects" OWNER TO "g_final_project"; CREATE TABLE IF NOT EXISTS "final_projects"."temperature_souwei_tan"( id serial, timestamp timestamp without time zone NOT NULL DEFAULT (current_timestamp AT TIME ZONE 'UTC+0'), temperature integer, PRIMARY KEY (id) ); ALTER TABLE "final_projects"."temperature_souwei_tan" OWNER to "g_final_project"; GRANT ALL ON ALL TABLES IN SCHEMA "final_projects" TO "g_final_project"; GRANT ALL ON ALL SEQUENCES IN SCHEMA "final_projects" TO "g_final_project";;

            1. M@marc_lin
                2020-10-06 09:54:43.842Z

                Hi @souwei,

                Please provide more information about your situation and print-screen.

                ty.

                1. Stan sou wei @souwei
                    2020-10-06 10:10:54.538Z

                    I try to find the temperature_souwei_tan but its not there for selection. i check with the url of mine, and it is fine and responded 200 ok. I am sorry for not so good at it. Thank you
                    http://final-project-demo-souwei-tan-level2-eks004.sa.wise-paas.com/

                    1. M@marc_lin
                        2020-10-06 10:57:10.039Z2020-10-06 11:20:12.165Z

                        Hi @souwei,

                        You might implement previous course unit of Level 2 then do the final project.
                        Please try to use the same method in the previous course unit to check the table in the Postgresql by PGadmin first.
                        (https://training.wise-paas.advantech.com/zh-TW/Level-II/content/DB-Test_Group_Locally)

                        ReplySolution
                        1. Stan sou wei @souwei
                            2020-10-07 03:36:14.031Z

                            hi sir, as mentioned by you, i able to create table and the timezone i set with timezone, but i did not showed value in dashboard.
                            is my coding wrong? i use the time zone code as below
                            timestamp timestamp with time zone
                            default (TIMESTAMP '2020-03-17 09:00:00' AT TIME ZONE 'JST')

                            1. M@marc_lin
                                2020-10-07 08:12:15.684Z

                                Hi @souwei,

                                How do you confirm the table you constructed?
                                Have you made sure the table you built in the Progressql by the PGadmin as I mentioned before?
                                If yes, try to check the data source setting of the table you use in the Dashboard.

                                1. Stan sou wei @souwei
                                    2020-10-07 08:20:45.844Z

                                    Hi sir, this is how i observed that i have create my table in postgresql. sorry if i did not show clear info to you. ok i will check the dashboard setting. thanks

                                    1. S@sk_chen
                                        2020-10-16 02:20:50.363Z

                                        Our final-project-demo architecture is to connect the local data to the wise-paas (external cloud) , so the host needs to use external host, you can view postgresql secret in portal-service and find the external host .

                                        host:Internal connection for use
                                        External host:External connection for use