Accessing the data from SQLalchemy query object?How to randomly select an item from a list?Accessing the index in 'for' loops?How to know if an object has an attribute in PythonDetermine the type of an object?Why can't Python parse this JSON data?null object in Python?SQLAlchemy ORDER BY DESCENDING?SQLAlchemy: What's the difference between flush() and commit()?How to access environment variable values?“Large data” work flows using pandas
How to officially communicate to a non-responsive colleague?
Can a user sell my software (MIT license) without modification?
Using a found spellbook as a Sorcerer-Wizard multiclass
How did they achieve the Gunslinger's shining eye effect in Westworld?
What can plausibly explain many of my very long and low-tech bridges?
PhD - Well known professor or well known school?
Is using haveibeenpwned to validate password strength rational?
How did students remember what to practise between lessons without any sheet music?
Using "subway" as name for London Underground?
If you had a giant cutting disc 60 miles diameter and rotated it 1000 rps, would the edge be traveling faster than light?
How to Analytically Solve this PDE?
Interview not reimboursed if offer is made but not accepted
Is an early checkout possible at a hotel before its reception opens?
Why doesn’t a normal window produce an apparent rainbow?
Frame failure sudden death?
How to chain Python function calls so the behaviour is as follows
Movie about a boy who was born old and grew young
Should an arbiter claim draw at a K+R vs K+R endgame?
Do simulator games use a realistic trajectory to get into orbit?
Is the term 'open source' a trademark?
Why doesn't Adrian Toomes give up Spider-Man's identity?
When conversion from Integer to Single may lose precision
How does an ordinary object become radioactive?
Payment instructions allegedly from HomeAway look fishy to me
Accessing the data from SQLalchemy query object?
How to randomly select an item from a list?Accessing the index in 'for' loops?How to know if an object has an attribute in PythonDetermine the type of an object?Why can't Python parse this JSON data?null object in Python?SQLAlchemy ORDER BY DESCENDING?SQLAlchemy: What's the difference between flush() and commit()?How to access environment variable values?“Large data” work flows using pandas
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am querying my database using the following command in python:
self.deleted_packages = model.Session.query(
model.Package).filter_by(state=model.State.DELETED)
And I am accessing the above value in pkg as show below:
for pkg in self.deleted_packages:
The output in pkg is :
<Package id=563e0da3-6916-4158-bc9f-f11bf92d3240
name=asdacaasas
title=asdacaasas
version= url= author= author_email= maintainer= maintainer_email= notes=
license_id=cc-by
type=dataset
owner_org=9b89900e-c4b8-413d-a8fe-edbe08641022
creator_user_id=30ad2d1c-f133-4458-9947-535e2718a898
metadata_created=2019-05-21 13:08:52.322015
metadata_modified=2019-05-21 13:08:59.946710
private=True
state=deleted
revision_id=5251e583-3a71-4189-8d4e-aaac8ac69927>
I just require the package id in a variable. And when I try to do the following:
p1=[x[0] for x in pkg]
I get the following error:
p1=[x[0] for x in pkg]
TypeError: 'Package' object is not iterable
Does someone know how can i store the value of just id : 563e0da3-6916-4158-bc9f-f11bf92d3240
in a variable from the above query result.?
python sqlalchemy
migrated from serverfault.com May 21 at 13:43
This question came from our site for system and network administrators.
|
show 1 more comment
I am querying my database using the following command in python:
self.deleted_packages = model.Session.query(
model.Package).filter_by(state=model.State.DELETED)
And I am accessing the above value in pkg as show below:
for pkg in self.deleted_packages:
The output in pkg is :
<Package id=563e0da3-6916-4158-bc9f-f11bf92d3240
name=asdacaasas
title=asdacaasas
version= url= author= author_email= maintainer= maintainer_email= notes=
license_id=cc-by
type=dataset
owner_org=9b89900e-c4b8-413d-a8fe-edbe08641022
creator_user_id=30ad2d1c-f133-4458-9947-535e2718a898
metadata_created=2019-05-21 13:08:52.322015
metadata_modified=2019-05-21 13:08:59.946710
private=True
state=deleted
revision_id=5251e583-3a71-4189-8d4e-aaac8ac69927>
I just require the package id in a variable. And when I try to do the following:
p1=[x[0] for x in pkg]
I get the following error:
p1=[x[0] for x in pkg]
TypeError: 'Package' object is not iterable
Does someone know how can i store the value of just id : 563e0da3-6916-4158-bc9f-f11bf92d3240
in a variable from the above query result.?
python sqlalchemy
migrated from serverfault.com May 21 at 13:43
This question came from our site for system and network administrators.
what library / package are you using ? SQLAlchemy ?
– bruno desthuilliers
May 21 at 13:47
@brunodesthuilliers , yes I am using SQLalchemy v1.3
– argg
May 21 at 14:04
@B.C can you please elaborate more on it?
– argg
May 21 at 14:05
@argg then have you searched the SQLAlchemy doc before posting here ? I'd be suprised if you didn't find the answer...
– bruno desthuilliers
May 21 at 14:08
Done @brunodesthuilliers, but why did you downvote.?
– argg
May 22 at 9:50
|
show 1 more comment
I am querying my database using the following command in python:
self.deleted_packages = model.Session.query(
model.Package).filter_by(state=model.State.DELETED)
And I am accessing the above value in pkg as show below:
for pkg in self.deleted_packages:
The output in pkg is :
<Package id=563e0da3-6916-4158-bc9f-f11bf92d3240
name=asdacaasas
title=asdacaasas
version= url= author= author_email= maintainer= maintainer_email= notes=
license_id=cc-by
type=dataset
owner_org=9b89900e-c4b8-413d-a8fe-edbe08641022
creator_user_id=30ad2d1c-f133-4458-9947-535e2718a898
metadata_created=2019-05-21 13:08:52.322015
metadata_modified=2019-05-21 13:08:59.946710
private=True
state=deleted
revision_id=5251e583-3a71-4189-8d4e-aaac8ac69927>
I just require the package id in a variable. And when I try to do the following:
p1=[x[0] for x in pkg]
I get the following error:
p1=[x[0] for x in pkg]
TypeError: 'Package' object is not iterable
Does someone know how can i store the value of just id : 563e0da3-6916-4158-bc9f-f11bf92d3240
in a variable from the above query result.?
python sqlalchemy
I am querying my database using the following command in python:
self.deleted_packages = model.Session.query(
model.Package).filter_by(state=model.State.DELETED)
And I am accessing the above value in pkg as show below:
for pkg in self.deleted_packages:
The output in pkg is :
<Package id=563e0da3-6916-4158-bc9f-f11bf92d3240
name=asdacaasas
title=asdacaasas
version= url= author= author_email= maintainer= maintainer_email= notes=
license_id=cc-by
type=dataset
owner_org=9b89900e-c4b8-413d-a8fe-edbe08641022
creator_user_id=30ad2d1c-f133-4458-9947-535e2718a898
metadata_created=2019-05-21 13:08:52.322015
metadata_modified=2019-05-21 13:08:59.946710
private=True
state=deleted
revision_id=5251e583-3a71-4189-8d4e-aaac8ac69927>
I just require the package id in a variable. And when I try to do the following:
p1=[x[0] for x in pkg]
I get the following error:
p1=[x[0] for x in pkg]
TypeError: 'Package' object is not iterable
Does someone know how can i store the value of just id : 563e0da3-6916-4158-bc9f-f11bf92d3240
in a variable from the above query result.?
python sqlalchemy
python sqlalchemy
edited May 23 at 16:28
B.C
155112
155112
asked May 21 at 13:37
arggargg
319
319
migrated from serverfault.com May 21 at 13:43
This question came from our site for system and network administrators.
migrated from serverfault.com May 21 at 13:43
This question came from our site for system and network administrators.
what library / package are you using ? SQLAlchemy ?
– bruno desthuilliers
May 21 at 13:47
@brunodesthuilliers , yes I am using SQLalchemy v1.3
– argg
May 21 at 14:04
@B.C can you please elaborate more on it?
– argg
May 21 at 14:05
@argg then have you searched the SQLAlchemy doc before posting here ? I'd be suprised if you didn't find the answer...
– bruno desthuilliers
May 21 at 14:08
Done @brunodesthuilliers, but why did you downvote.?
– argg
May 22 at 9:50
|
show 1 more comment
what library / package are you using ? SQLAlchemy ?
– bruno desthuilliers
May 21 at 13:47
@brunodesthuilliers , yes I am using SQLalchemy v1.3
– argg
May 21 at 14:04
@B.C can you please elaborate more on it?
– argg
May 21 at 14:05
@argg then have you searched the SQLAlchemy doc before posting here ? I'd be suprised if you didn't find the answer...
– bruno desthuilliers
May 21 at 14:08
Done @brunodesthuilliers, but why did you downvote.?
– argg
May 22 at 9:50
what library / package are you using ? SQLAlchemy ?
– bruno desthuilliers
May 21 at 13:47
what library / package are you using ? SQLAlchemy ?
– bruno desthuilliers
May 21 at 13:47
@brunodesthuilliers , yes I am using SQLalchemy v1.3
– argg
May 21 at 14:04
@brunodesthuilliers , yes I am using SQLalchemy v1.3
– argg
May 21 at 14:04
@B.C can you please elaborate more on it?
– argg
May 21 at 14:05
@B.C can you please elaborate more on it?
– argg
May 21 at 14:05
@argg then have you searched the SQLAlchemy doc before posting here ? I'd be suprised if you didn't find the answer...
– bruno desthuilliers
May 21 at 14:08
@argg then have you searched the SQLAlchemy doc before posting here ? I'd be suprised if you didn't find the answer...
– bruno desthuilliers
May 21 at 14:08
Done @brunodesthuilliers, but why did you downvote.?
– argg
May 22 at 9:50
Done @brunodesthuilliers, but why did you downvote.?
– argg
May 22 at 9:50
|
show 1 more comment
1 Answer
1
active
oldest
votes
You should read the docs for SQLalchemy (I am getting this context from the comments).
There are a few examples examples that can highlight how you could get around your issue.
An example from the documentation linked in this answer (not relevant to your exact case!):
>>> for row in session.query(User, User.name).all():
... print(row.User, row.name)
With the output being:
<User(name='ed', fullname='Ed Jones', nickname='eddie')> ed
<User(name='wendy', fullname='Wendy Williams', nickname='windy')> wendy
<User(name='mary', fullname='Mary Contrary', nickname='mary')> mary
<User(name='fred', fullname='Fred Flintstone', nickname='freddy')> fred
So in your case the pkg
variable (an object of the Package
class) might be similar to the User
object in the example above and the name
contents is accessed by row.name
.
So your case might have something like pkg.id
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56239684%2faccessing-the-data-from-sqlalchemy-query-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should read the docs for SQLalchemy (I am getting this context from the comments).
There are a few examples examples that can highlight how you could get around your issue.
An example from the documentation linked in this answer (not relevant to your exact case!):
>>> for row in session.query(User, User.name).all():
... print(row.User, row.name)
With the output being:
<User(name='ed', fullname='Ed Jones', nickname='eddie')> ed
<User(name='wendy', fullname='Wendy Williams', nickname='windy')> wendy
<User(name='mary', fullname='Mary Contrary', nickname='mary')> mary
<User(name='fred', fullname='Fred Flintstone', nickname='freddy')> fred
So in your case the pkg
variable (an object of the Package
class) might be similar to the User
object in the example above and the name
contents is accessed by row.name
.
So your case might have something like pkg.id
add a comment |
You should read the docs for SQLalchemy (I am getting this context from the comments).
There are a few examples examples that can highlight how you could get around your issue.
An example from the documentation linked in this answer (not relevant to your exact case!):
>>> for row in session.query(User, User.name).all():
... print(row.User, row.name)
With the output being:
<User(name='ed', fullname='Ed Jones', nickname='eddie')> ed
<User(name='wendy', fullname='Wendy Williams', nickname='windy')> wendy
<User(name='mary', fullname='Mary Contrary', nickname='mary')> mary
<User(name='fred', fullname='Fred Flintstone', nickname='freddy')> fred
So in your case the pkg
variable (an object of the Package
class) might be similar to the User
object in the example above and the name
contents is accessed by row.name
.
So your case might have something like pkg.id
add a comment |
You should read the docs for SQLalchemy (I am getting this context from the comments).
There are a few examples examples that can highlight how you could get around your issue.
An example from the documentation linked in this answer (not relevant to your exact case!):
>>> for row in session.query(User, User.name).all():
... print(row.User, row.name)
With the output being:
<User(name='ed', fullname='Ed Jones', nickname='eddie')> ed
<User(name='wendy', fullname='Wendy Williams', nickname='windy')> wendy
<User(name='mary', fullname='Mary Contrary', nickname='mary')> mary
<User(name='fred', fullname='Fred Flintstone', nickname='freddy')> fred
So in your case the pkg
variable (an object of the Package
class) might be similar to the User
object in the example above and the name
contents is accessed by row.name
.
So your case might have something like pkg.id
You should read the docs for SQLalchemy (I am getting this context from the comments).
There are a few examples examples that can highlight how you could get around your issue.
An example from the documentation linked in this answer (not relevant to your exact case!):
>>> for row in session.query(User, User.name).all():
... print(row.User, row.name)
With the output being:
<User(name='ed', fullname='Ed Jones', nickname='eddie')> ed
<User(name='wendy', fullname='Wendy Williams', nickname='windy')> wendy
<User(name='mary', fullname='Mary Contrary', nickname='mary')> mary
<User(name='fred', fullname='Fred Flintstone', nickname='freddy')> fred
So in your case the pkg
variable (an object of the Package
class) might be similar to the User
object in the example above and the name
contents is accessed by row.name
.
So your case might have something like pkg.id
answered May 21 at 14:37
B.CB.C
155112
155112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56239684%2faccessing-the-data-from-sqlalchemy-query-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what library / package are you using ? SQLAlchemy ?
– bruno desthuilliers
May 21 at 13:47
@brunodesthuilliers , yes I am using SQLalchemy v1.3
– argg
May 21 at 14:04
@B.C can you please elaborate more on it?
– argg
May 21 at 14:05
@argg then have you searched the SQLAlchemy doc before posting here ? I'd be suprised if you didn't find the answer...
– bruno desthuilliers
May 21 at 14:08
Done @brunodesthuilliers, but why did you downvote.?
– argg
May 22 at 9:50