# Using Plotly to plot data from Postgre SQL database

**URL:** <https://community.plotly.com/t/using-plotly-to-plot-data-from-postgre-sql-database/1711>\
**Category:** 📊 Plotly Python\
**Created:** [August 2, 2016, 5:18am UTC](https://community.plotly.com/t/using-plotly-to-plot-data-from-postgre-sql-database/1711 "2016-08-02T05:18:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saishibu38380](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@saishibu38380](https://community.plotly.com/u/saishibu38380)\
**Post date:** [August 2, 2016, 5:18am UTC](https://community.plotly.com/t/using-plotly-to-plot-data-from-postgre-sql-database/1711/1 "2016-08-02T05:18:43Z")

</div>

Hello all,

I’m trying to plot a graph with time in Xaxis and Power( from my smart meter) in Yaxis.  
time is in TEXT format ( Sat Jul 9 21:34:04 2016) and Power is in Float format (20.56)

i read these from the database and save it to an array  
`trace = py.Scatter(x=time,y=power)`

and they use plotly offline to plot the graph

`plotly.offline.plot(trace)`

I get an error saying  
" Invalid ‘figure\_or\_data’ argument. Plotly will not be able to properly parse the resulting JSON. If you want to send this ‘figure\_or\_data’ to Plotly anyways (not recommended), you can set ‘validate=False’ as a plot option.  
Here is why you’re seeing this error:

```
Path to Error: ['y']

Valid attributes for 'figure' at path[] under parents[]:

['layout', 'data']

```

What is the error in the program?  
I could plot by manually giving X and Y values.  
Is it because of wrong time format?

---

<div class="post-metadata">

**Author:** ![chelsea](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chelsea/32/196_2.png) [@chelsea](https://community.plotly.com/u/chelsea)\
**Post date:** [August 2, 2016, 6:36pm UTC](https://community.plotly.com/t/using-plotly-to-plot-data-from-postgre-sql-database/1711/2 "2016-08-02T18:36:08Z")

</div>

Hi there,  
It looks like you may be skipping the step of creating the data array.  
So you could try:  
`trace = py.Scatter(x=time,y=power)`  
`data = [trace]`  
`plotly.offline.plot(data)`

or

`trace = py.Scatter(x=time,y=power)`  
`plotly.offline.plot([trace])`

You can find more information on the python getting started page: [https://plot.ly/python/getting-started/#start-plotting-online](https://plot.ly/python/getting-started/#start-plotting-online) //  
[https://plot.ly/python/getting-started/#initialization-for-offline-plotting](https://plot.ly/python/getting-started/#initialization-for-offline-plotting)
