title: how to fetch data from postgresql using d3.js
body: <p>Previously I am using <strong>CSV</strong> to store data and by that, I am making the graphs.
  But now I want to know how to get data from <strong>PostgreSQL</strong> using <strong>d3.js</strong>.</p>
  
  <p>If anyone knows please help me I am totally new user to PostgreSQL.</p>
  
  <pre><code>import psycopg2
  import sys
  from  flask import Flask,render_template
  import os
  
  os.chmod("/home/dell/Charts/static/data/data.csv", 0o777)
  con = None
  con = psycopg2.connect("host='localhost' dbname='mydb' user='postgres' password='Password'")  
  cur = con.cursor()
  
  cur.execute("""COPY data_lc TO '/home/dell/Charts/static/data/data.csv' DELIMITER ',' CSV HEADER;""")
  
  cur.close()
  </code></pre>
  
  <p><strong>This Code working Properly</strong></p>
  
  <p>But I want to know is there any way to get the data directly from the <strong>PostgreSQL</strong> by the <strong>D3.js</strong></p>
  
  <p><strong>html code</strong></p>
  
  <pre><code>&lt;div class="panel panel-default"&gt;
      &lt;div class="panel-heading"&gt;
          &lt;h4&gt;LineChart&lt;/h4&gt;
      &lt;/div&gt;
      &lt;div class="panel-body"&gt;
          &lt;div id="linechart"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;script src="static/js/Linechart.js"&gt;&lt;/script&gt;
  </code></pre>