How to convert sqlalchemy to json format
My sample code is below...
I'm struggling using various packages..etc. to convert.. the result that
was received under variable rows.
from flask import Flask, jsonify, json
from flask_restful import reqparse, abort, Api, Resource
from sqlalchemy.ext.d
On Sunday, October 16, 2016 at 10:09:00 AM UTC-4, Mike Bayer wrote:
>
>
>
> The simplest way is probably to set the creation order of the column to
> be at the top:
>
> col = Column(...)
> col._creation_order = -10
Great. I will use _creation_order. Thanks.
By the way, in view of PEP 520
(ht
Hi!
There is any option to select JOIN result as dict?
For example I have:
*table1*
t1c1| t1c2
-+
1 | one
2 | two
3 | three
*table2*
t2c1 | t2c2 | t2c3
-+---+---
11 | qwe | 1
22 | rty | 2
33 | zxcvb| 1
where
t2c3 from *table2 *is a foreign key
On a related note, is there something like after_create events for indexes
and sequences? There doesn't seem to be.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
E
On 10/17/2016 09:32 AM, Seth P wrote:
On a related note, is there something like after_create events for
indexes and sequences? There doesn't seem to be.
the indexes and sequences are generated in the context of the Table in
which they are associated, so I'd just use the table level after_cr
On 10/17/2016 08:38 AM, Seth P wrote:
On Sunday, October 16, 2016 at 10:09:00 AM UTC-4, Mike Bayer wrote:
The simplest way is probably to set the creation order of the column to
be at the top:
col = Column(...)
col._creation_order = -10
Great. I will use _creation_order. T
On Monday, October 17, 2016 at 11:24:43 AM UTC-4, Mike Bayer wrote:
>
> However, I don't see how the ordered attributes fixes anything in terms
> of mixins. If a mixin wants its columns at the beginning, or the end,
> all of that can be upended by the presence of other mixins and those
> mixin
Your query's underlying sql returns multiple rows. You can cast those
results into a dict in Python.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See
On 10/17/2016 11:51 AM, Seth P wrote:
On Monday, October 17, 2016 at 11:24:43 AM UTC-4, Mike Bayer wrote:
However, I don't see how the ordered attributes fixes anything in terms
of mixins. If a mixin wants its columns at the beginning, or the end,
all of that can be upended by th
Alfred-
I'm sorry you felt offended and misinterpreted my comment. I did not think
you were unskilled in the slightest. Quite the opposite (i did look you
up).
Your concerns and solutions were in-line with to how every highly
experienced lower-level engineer I've worked with has approached a
SQLAlchemy release 1.1.2 is now available.
Release 1.1.2 includes a small handful of bug fixes, including some
small regressions from the 1.0 series, some ORM loading improvements,
and a fix to the new PostgreSQL ON CONFLICT feature.
Changelog for 1.1.2 is at: http://www.sqlalchemy.org/chang
I realize that the orm really wants/needs a table to have a primary key:
http://docs.sqlalchemy.org/en/rel_1_1/faq/ormconfiguration.html?#how-do-i-map-a-table-that-has-no-primary-key
Alas I have to deal with an existing table with no primary key. That said,
it does have a unique constraint on a
converting to json would be like this:
for row in rows:
converted = json.dumps(row)
it is possible that your json encoder can not handle a particular
sqlalchemy object. if that is the case you will need to build your own
json dumps function or encoder that can adapt your data. flask
On 10/17/2016 03:36 PM, Seth P wrote:
I realize that the orm really wants/needs a table to have a primary key:
http://docs.sqlalchemy.org/en/rel_1_1/faq/ormconfiguration.html?#how-do-i-map-a-table-that-has-no-primary-key
Alas I have to deal with an existing table with no primary key. That
said
On Monday, October 17, 2016 at 3:58:36 PM UTC-4, Mike Bayer wrote:
>
> that error is there right now because we don't emit the "col IS NULL"
> SQL within that section of the persistence code.
>
> took me a long time to find the history on this because I thought it had
> been discussed but looks
Hi,
The api output comes up with the special charaters such as newline and \.
The output looks good when i'm executing from the IDE. but while looking
towards the url, it shows up like below and not in good format. It
becomes trouble while on the retrival.
"[{\"INFO\": null, \"SEQ\": 1.0,
I was not offended personally, however I was annoyed that a conversation
on a topic that I felt helpful to the community was being shut down.
When I shared the response I got the feedback was that the received
answer fell under was the umbrella of "mansplainining" and how a
response such as th
17 matches
Mail list logo