Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Have you reconsidered a computer career?


devel / comp.lang.python / Re: flask app convert sql query to python plotly

SubjectAuthor
* flask app convert sql query to python plotlyAbdellah ALAOUI ISMAILI
`- Re: flask app convert sql query to python plotlyPython

1
flask app convert sql query to python plotly

<48b7f8b7-9aef-4cbc-8ecb-b2d214aceb86n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=22097&group=comp.lang.python#22097

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:f50b:0:b0:680:d577:baf6 with SMTP id l11-20020a37f50b000000b00680d577baf6mr10011221qkk.328.1648925522572;
Sat, 02 Apr 2022 11:52:02 -0700 (PDT)
X-Received: by 2002:ad4:594b:0:b0:443:536f:52a9 with SMTP id
eo11-20020ad4594b000000b00443536f52a9mr12278500qvb.73.1648925522391; Sat, 02
Apr 2022 11:52:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 2 Apr 2022 11:52:02 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=197.253.225.221; posting-account=7y2HgQoAAAAuYInmUJz2s-7SsAXTJXV2
NNTP-Posting-Host: 197.253.225.221
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <48b7f8b7-9aef-4cbc-8ecb-b2d214aceb86n@googlegroups.com>
Subject: flask app convert sql query to python plotly
From: my.alaoui.ia@gmail.com (Abdellah ALAOUI ISMAILI)
Injection-Date: Sat, 02 Apr 2022 18:52:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 31
 by: Abdellah ALAOUI ISMA - Sat, 2 Apr 2022 18:52 UTC

Hello,
i would like to convert in my flask app an SQL query to an plotly pie chart using pandas. this is my code :

def query_tickets_status() :
query_result = pd.read_sql ("""
SELECT COUNT(*)count_status, status
FROM tickets
GROUP BY status""", con = mydc_db)
return query_result

labels_statut = query_tickets_status['status']
values_statut = query_tickets_status['count_status']

fig = go.Figure(data=[go.Pie(labels=labels_statut, values=values_statut)])
graphSuppliers = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)

return render_template('admin/dashboard.html', graphSuppliers = graphSuppliers)
this is my template file.

<html>
<body>
<h1>Your Plotly Chart</h1>
<div id='chart' class='chart'></div>
</body>
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<script type='text/javascript'>
var graphs = {{graphSuppliers | safe}};
Plotly.plot('chart',graphs,{});
</script></html>
but I get this error :

TypeError: 'function' object is not subscriptable

Re: flask app convert sql query to python plotly

<t2a692$9vv$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=22098&group=comp.lang.python#22098

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!7a25jG6pUKCqa0zKnKnvdg.user.46.165.242.75.POSTED!not-for-mail
From: python@example.invalid (Python)
Newsgroups: comp.lang.python
Subject: Re: flask app convert sql query to python plotly
Date: Sat, 2 Apr 2022 20:56:40 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t2a692$9vv$1@gioia.aioe.org>
References: <48b7f8b7-9aef-4cbc-8ecb-b2d214aceb86n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="10239"; posting-host="7a25jG6pUKCqa0zKnKnvdg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Content-Language: fr
X-Notice: Filtered by postfilter v. 0.9.2
 by: Python - Sat, 2 Apr 2022 18:56 UTC

Abdellah ALAOUI ISMAILI wrote:
> def query_tickets_status() :
> query_result = pd.read_sql ("""
> SELECT COUNT(*)count_status, status
> FROM tickets
> GROUP BY status""", con = mydc_db)
> return query_result
>
> labels_statut = query_tickets_status['status']

labels_statut = query_tickets_status()['status']


devel / comp.lang.python / Re: flask app convert sql query to python plotly

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor