How to replace id with attribute corresponding to id of another table?

0 votes

Using SQLAlchemy, I can query a bunch of files for their names and who created them:

>>> DBSession.query(Version.name, Version.created_by_id).filter(Version.id.in_(versions_list)).all()
[('file1', 1), ('file2', 2), ('file3', 3)]

The Version.created_by_id corresponds to the user ID. All users reside in a separate table:

>>> DBSession.query(User.id, User.name).all()
[(1, 'Abe'), (2, 'Cal'), (3, 'Dan')]

How can I, with one query, get this result back when I query my files?

[('file1', 'Abe'), ('file2', 'Cal'), ('file3', 'Dan')]

Oct 3, 2018 in Python by eatcodesleeprepeat
• 4,670 points
19 views

1 answer to this question.

0 votes
Try looking the given link for better understanding
http://www.mysqltutorial.org/mysql-replace.aspx
answered Oct 3, 2018 by Priyaj
• 56,160 points

Related Questions In Python

0 votes
1 answer

How to get rid of tensorflow verbose messages with Keras?

If you are using TensorFlow 0.12, you ...READ MORE

answered Jan 24 in Python by SDeb
• 12,280 points
154 views
0 votes
1 answer

How to zip with a list output in Python instead of a tuple output?

Good question - Considering that you are ...READ MORE

answered Feb 7 in Python by Nymeria
• 3,500 points
39 views
0 votes
1 answer

How to get domain name of email ID?

You can use the split method to split the ...READ MORE

answered Mar 28 in Python by Firoz
41 views
0 votes
1 answer

Replace values in data frame with valued of another dataframe.

Hi @Puneeth, you use something like this: f ...READ MORE

answered May 30 in Python by Ashish
20 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
+1 vote
1 answer

How to replace id with attribute corresponding to id of another table?

Use the following query statement and let ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 56,160 points
20 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 56,160 points
592 views