<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Snowflake integration issue]]></title><description><![CDATA[<p>I have template to working with a node js script to get data from snowflake but it is getting data but it is not showing up in the template result.</p>
<pre><code>&lt;html&gt;

&lt;head&gt;
    &lt;style&gt;
        {
                {
                asset &quot;sd-styles.css&quot;&quot;utf8&quot;
            }
        }
    &lt;/style&gt;
&lt;/head&gt;
        &lt;tbody class=&quot;posts&quot;&gt;
            &lt;tr&gt;
                &lt;th class=&quot;t-center&quot;&gt;State&lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt;Credits&lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt;Actual Cash&lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt; Unrevealed &lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt; Customer Funds &lt;/th&gt;
            &lt;/tr&gt;
            {{#each posts}}
            &lt;tr style=&quot;height: 20px, class=&quot;post&quot;&gt;
            &lt;td dclass=&quot;t-right&quot; data-cell-type=&quot;text&quot;&gt;{{STATE}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_CREDITS}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_ACTUAL_CASH}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_UNREVEALED}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_CUSTOMER_FUNDS}}&lt;/td&gt;
            &lt;/tr&gt;
            {{/each}}
        &lt;/tbody&gt;
    &lt;/table&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>
<p>Script nodejs:</p>
<pre><code>async function beforeRender(req, res) {
  var snowflake = require('snowflake-sdk');
    const connection = snowflake.createConnection({
    account: '******.eu-west-2.aws',
    username: '*****',
    password: '*********' 
    //clientSessionKeepAlive: true     
  });
         connection.connect( 
          function(err, conn) {
            if (err) {
                console.error('Unable to connect: ' + err.message);
                } 
            else {
                console.log('Successfully connected to Snowflake.');
                // Optional: store the connection ID.
                //connection_ID = conn.getId();
                }
        }
    )
        connection.execute({
        sqlText: 'select * FROM SUPERDRAFT_PROD.SD_REPORTS.VW_DAILY_STATE_BALANCE_SDPRO',
        complete: function(err, stmt, rows) {
          if (err) {
            console.error('Failed to execute statement due to the following error: ' + err.message);
          } else {
            console.log('Number of rows produced: ' + rows.length);
            console.log(JSON.stringify(rows));
            req.data.posts = rows
          }
        }
      });
        connection.execute({
              sqlText: 'select * FROM SUPERDRAFT_PROD.SD_REPORTS.VW_DAILY_STATE_BALANCE_SDPRO;',
              complete: function (err, stmt, rows)
              {
                  var stream = stmt.streamRows();
                  stream.on('data', function (row)
                  {
                      console.log(row);
                      console.log(JSON.stringify(row));
                  });
                  stream.on('end', function (row)
                  {
                      console.log('All rows consumed');
                  });

                  req.data.posts = stream
              }
            })
        connection.destroy(function(err, conn) {
        if (err) {
          console.error('Unable to disconnect: ' + err.message);
        } else {
          console.log('Disconnected connection with id: ' + connection.getId());
        }
  })
}
</code></pre>
<p>Logs debug details:</p>
<pre><code>
info
+0
Render request 18 queued for execution and waiting for availible worker
info
+15
Starting rendering request 18 (user: admin)
info
+0
Rendering template { name: daily_state_balance_template, recipe: chrome-pdf, engine: handlebars, preview: true }
debug
+1
Data item not defined for this template.
debug
+4
Executing script daily_state_balance (beforeRender)
debug
+532
Base url not specified, skipping its injection.
debug
+1
Rendering engine handlebars
debug
+32
Executing recipe chrome-pdf
debug
+6
Converting with chrome HeadlessChrome/98.0.4758.0 using chrome-pool strategy
debug
+64
Page request: GET (document) file:///tmp/jsreport/autocleanup/fb23f58e-09f7-43db-ad7d-0859e4b305fb-chrome-pdf.html
debug
+20
Page request finished: GET (document) file:///tmp/jsreport/autocleanup/fb23f58e-09f7-43db-ad7d-0859e4b305fb-chrome-pdf.html
debug
+10
Running chrome with params {&quot;printBackground&quot;:true,&quot;timeout&quot;:59409,&quot;margin&quot;:{}}
debug
+25
Skipping storing report.
info
+1
Rendering request 18 finished in 712 ms
</code></pre>
<p>We can see the request is reaching to snowflake and it success</p>
<p><img src="/uploads/files/1664389636456-upload-a89620f1-5998-469f-8e50-28147094a695-resized.png" alt="0_1664389634100_upload-a89620f1-5998-469f-8e50-28147094a695" class="img-responsive img-markdown" /></p>
<p>Log debug details, see you can see the output from the snowflake here:</p>
<pre><code>
info
+0
Render request 692 queued for execution and waiting for availible worker
info
+19
Starting rendering request 692 (user: admin)
info
+1
Rendering template { name: daily_state_balance_template, recipe: chrome-pdf, engine: handlebars, preview: true }
debug
+3
Data item not defined for this template.
debug
+18
Executing script daily_state_balance (beforeRender)
debug
+657
Base url not specified, skipping its injection.
debug
+0
Rendering engine handlebars
debug
+29
Executing recipe chrome-pdf
debug
+437
Successfully connected to Snowflake.
error
+157
Failed to execute statement due to the following error: Unable to perform operation using terminated connection.
debug
+2
Disconnected connection with id: 5728cff4-8369-4326-8b37-febf90f0840c
debug
+157
{
  STATE: 'NH',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 684510.37,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 684510.37
}
debug
+0
{
  STATE: 'ON',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 1698745,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 1698745
}
debug
+0
{
  STATE: 'Ohio',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 1437135,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 1437135
}
debug
+0
{
  STATE: 'Wisconsin',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 1283727,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 1283727
}
debug
+1
All rows consumed
debug
+254
Converting with chrome HeadlessChrome/98.0.4758.0 using chrome-pool strategy
debug
+300
Page request: GET (document) file:///tmp/jsreport/autocleanup/0af73c52-35b3-42c4-a534-3f42b4f1e068-chrome-pdf.html
debug
+22
Page request finished: GET (document) file:///tmp/jsreport/autocleanup/0af73c52-35b3-42c4-a534-3f42b4f1e068-chrome-pdf.html
debug
+29
Running chrome with params {&quot;printBackground&quot;:true,&quot;timeout&quot;:59121,&quot;margin&quot;:{}}
debug
+49
Skipping storing report.
info
+0
Rendering request 692 finished in 2135 ms</code></pre>
]]></description><link>https://forum.jsreport.net/topic/2583/snowflake-integration-issue</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 06:38:45 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/2583.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Sep 2022 18:31:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Snowflake integration issue on Thu, 29 Sep 2022 13:05:57 GMT]]></title><description><![CDATA[<p>I have template to working with a node js script to get data from snowflake but it is getting data but it is not showing up in the template result.</p>
<pre><code>&lt;html&gt;

&lt;head&gt;
    &lt;style&gt;
        {
                {
                asset &quot;sd-styles.css&quot;&quot;utf8&quot;
            }
        }
    &lt;/style&gt;
&lt;/head&gt;
        &lt;tbody class=&quot;posts&quot;&gt;
            &lt;tr&gt;
                &lt;th class=&quot;t-center&quot;&gt;State&lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt;Credits&lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt;Actual Cash&lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt; Unrevealed &lt;/th&gt;
                &lt;th class=&quot;t-center&quot;&gt; Customer Funds &lt;/th&gt;
            &lt;/tr&gt;
            {{#each posts}}
            &lt;tr style=&quot;height: 20px, class=&quot;post&quot;&gt;
            &lt;td dclass=&quot;t-right&quot; data-cell-type=&quot;text&quot;&gt;{{STATE}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_CREDITS}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_ACTUAL_CASH}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_UNREVEALED}}&lt;/td&gt;
                &lt;td class=&quot;t-right&quot; data-cell-type=&quot;number&quot; data-cell-format-str=&quot;0.00&quot;&gt;{{STATE_CUSTOMER_FUNDS}}&lt;/td&gt;
            &lt;/tr&gt;
            {{/each}}
        &lt;/tbody&gt;
    &lt;/table&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>
<p>Script nodejs:</p>
<pre><code>async function beforeRender(req, res) {
  var snowflake = require('snowflake-sdk');
    const connection = snowflake.createConnection({
    account: '******.eu-west-2.aws',
    username: '*****',
    password: '*********' 
    //clientSessionKeepAlive: true     
  });
         connection.connect( 
          function(err, conn) {
            if (err) {
                console.error('Unable to connect: ' + err.message);
                } 
            else {
                console.log('Successfully connected to Snowflake.');
                // Optional: store the connection ID.
                //connection_ID = conn.getId();
                }
        }
    )
        connection.execute({
        sqlText: 'select * FROM SUPERDRAFT_PROD.SD_REPORTS.VW_DAILY_STATE_BALANCE_SDPRO',
        complete: function(err, stmt, rows) {
          if (err) {
            console.error('Failed to execute statement due to the following error: ' + err.message);
          } else {
            console.log('Number of rows produced: ' + rows.length);
            console.log(JSON.stringify(rows));
            req.data.posts = rows
          }
        }
      });
        connection.execute({
              sqlText: 'select * FROM SUPERDRAFT_PROD.SD_REPORTS.VW_DAILY_STATE_BALANCE_SDPRO;',
              complete: function (err, stmt, rows)
              {
                  var stream = stmt.streamRows();
                  stream.on('data', function (row)
                  {
                      console.log(row);
                      console.log(JSON.stringify(row));
                  });
                  stream.on('end', function (row)
                  {
                      console.log('All rows consumed');
                  });

                  req.data.posts = stream
              }
            })
        connection.destroy(function(err, conn) {
        if (err) {
          console.error('Unable to disconnect: ' + err.message);
        } else {
          console.log('Disconnected connection with id: ' + connection.getId());
        }
  })
}
</code></pre>
<p>Logs debug details:</p>
<pre><code>
info
+0
Render request 18 queued for execution and waiting for availible worker
info
+15
Starting rendering request 18 (user: admin)
info
+0
Rendering template { name: daily_state_balance_template, recipe: chrome-pdf, engine: handlebars, preview: true }
debug
+1
Data item not defined for this template.
debug
+4
Executing script daily_state_balance (beforeRender)
debug
+532
Base url not specified, skipping its injection.
debug
+1
Rendering engine handlebars
debug
+32
Executing recipe chrome-pdf
debug
+6
Converting with chrome HeadlessChrome/98.0.4758.0 using chrome-pool strategy
debug
+64
Page request: GET (document) file:///tmp/jsreport/autocleanup/fb23f58e-09f7-43db-ad7d-0859e4b305fb-chrome-pdf.html
debug
+20
Page request finished: GET (document) file:///tmp/jsreport/autocleanup/fb23f58e-09f7-43db-ad7d-0859e4b305fb-chrome-pdf.html
debug
+10
Running chrome with params {&quot;printBackground&quot;:true,&quot;timeout&quot;:59409,&quot;margin&quot;:{}}
debug
+25
Skipping storing report.
info
+1
Rendering request 18 finished in 712 ms
</code></pre>
<p>We can see the request is reaching to snowflake and it success</p>
<p><img src="/uploads/files/1664389636456-upload-a89620f1-5998-469f-8e50-28147094a695-resized.png" alt="0_1664389634100_upload-a89620f1-5998-469f-8e50-28147094a695" class="img-responsive img-markdown" /></p>
<p>Log debug details, see you can see the output from the snowflake here:</p>
<pre><code>
info
+0
Render request 692 queued for execution and waiting for availible worker
info
+19
Starting rendering request 692 (user: admin)
info
+1
Rendering template { name: daily_state_balance_template, recipe: chrome-pdf, engine: handlebars, preview: true }
debug
+3
Data item not defined for this template.
debug
+18
Executing script daily_state_balance (beforeRender)
debug
+657
Base url not specified, skipping its injection.
debug
+0
Rendering engine handlebars
debug
+29
Executing recipe chrome-pdf
debug
+437
Successfully connected to Snowflake.
error
+157
Failed to execute statement due to the following error: Unable to perform operation using terminated connection.
debug
+2
Disconnected connection with id: 5728cff4-8369-4326-8b37-febf90f0840c
debug
+157
{
  STATE: 'NH',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 684510.37,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 684510.37
}
debug
+0
{
  STATE: 'ON',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 1698745,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 1698745
}
debug
+0
{
  STATE: 'Ohio',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 1437135,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 1437135
}
debug
+0
{
  STATE: 'Wisconsin',
  STATE_CREDITS: 0,
  STATE_ACTUAL_CASH: 1283727,
  STATE_UNREVEALED: 0,
  STATE_CUSTOMER_FUNDS: 1283727
}
debug
+1
All rows consumed
debug
+254
Converting with chrome HeadlessChrome/98.0.4758.0 using chrome-pool strategy
debug
+300
Page request: GET (document) file:///tmp/jsreport/autocleanup/0af73c52-35b3-42c4-a534-3f42b4f1e068-chrome-pdf.html
debug
+22
Page request finished: GET (document) file:///tmp/jsreport/autocleanup/0af73c52-35b3-42c4-a534-3f42b4f1e068-chrome-pdf.html
debug
+29
Running chrome with params {&quot;printBackground&quot;:true,&quot;timeout&quot;:59121,&quot;margin&quot;:{}}
debug
+49
Skipping storing report.
info
+0
Rendering request 692 finished in 2135 ms</code></pre>
]]></description><link>https://forum.jsreport.net/post/11205</link><guid isPermaLink="true">https://forum.jsreport.net/post/11205</guid><dc:creator><![CDATA[Anandanr]]></dc:creator><pubDate>Thu, 29 Sep 2022 13:05:57 GMT</pubDate></item><item><title><![CDATA[Reply to Snowflake integration issue on Invalid Date]]></title><description><![CDATA[<p>Your code badly mixes callbacks with async/await promises.<br />
The <code>beforeRender</code> already finishes, but your callbacks to connection.execute haven't been invoked yet.<br />
Try to take your code outside the jsreport into a plain nodejs file and debug it to get a better understanding. This isn't about jsreport but proper javascript coding. You need to set to <code>req.data</code> before the function <code>beforeRender</code> actually exits.</p>
]]></description><link>https://forum.jsreport.net/post/11221</link><guid isPermaLink="true">https://forum.jsreport.net/post/11221</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>