Re: [sqlalchemy] What is the terminology for ...?
Thanks David On Thursday, June 11, 2015 at 11:53:44 AM UTC-7, David Allouche wrote: > > > On 11 Jun 2015, at 19:09, Tony C > wrote: > > I'm new to databases, SQL, and SQLAlchemy. I've been going through the > tutorials and docs at SQLAlchemy.org trying to find a solution to > what I believe is a very simple issue with database quiries, however I'm > quite uncertain of the terminology. > > I'm using the declarative form of SQL queries. > > When doing a query on a table with a foreign key, I want to query the data > in the "referenced table". > In uncertain terms, I want the query to be "recursive"- meaning, I want > all of the data from the referenced tables, not just the values of the > foreign keys. > However, I don't know what the exact terminology is in order to search > through help. > > Here is an example: (this is exploratory code only. Error handling and > imports left out for brevity) > > http://pastebin.com/HpNB64t4 > > 1. What is the correct terminology for a recursive query, in SQLAlchemy > parlance? > 2. How do I tell SQL Alchemy to do that? > > > You probably want to read about the following topics in the SQLAlchemy > documentation. > >- relation >- joinedload > > > Regards. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] Re: What is the SQLAlchemy terminology for ..?
Thanks Jonathan, >>Your question and example are both a bit confusing Yes-as I mentioned in my post, and I am new to databases and SQL,so I don't know how to ask for what I'm looking for. After creating the relationship that you mentioned, my queries now pull the data from the referenced tables. On Thursday, June 11, 2015 at 10:47:17 AM UTC-7, Jonathan Vanasco wrote: > > Your question and example are both a bit confusing. I'll try to impart > some knowledge that can help you re-focus an ask. > > 1. In your example, `Session.query(CaseTestInstance)` will return all the > data in the `cases_test_instance` table. > 2. "Recursive Queries" can mean a few things (and is often used with > Contextual Table Expressions or functions that use the `with recursive` > operator), and are usually a bit of an advanced topic. I think you mean > something else. > 3. It sounds like you want to load associated or related data to the > foreign keys. In your example, I you would need to create classes that > reflect the tables 'cases_test`, `auth_user` and `slaves_groups`. In > SqlAlchemy to get this data you must define the classes/tables and then set > a `relationship` (and optionally a backref, so the relationship is > accessible from both objects). You can then automatically load the > relationship with one of the many techniques, or use a table join. > > The ForeignKey merely states that the column in your table should/must > correspond to the column in the other table. It implies that there is a > relationship, but you must explicitly declare the relationship in your > code. a column like `slave_group_id` would usually be paired with a > relationship called `slave_group`. > > advanced db designs might have multiple declared relationships that are > built off the ForeignKey used in conjunction with multiple modifiers. > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] What is the SQLAlchemy terminology for ..?
Hi I'm new to databases, SQL, and SQLAlchemy. I've been going through the tutorials and docs at SQLAlchemy.org trying to find a solution to what I believe is a very simple issue with database quiries, however I'm quite uncertain of the terminology. I'm using the declarative form of SQL queries. When doing a query on a table with a foreign key, I want to query the data in the "referenced table". In uncertain terms, I want the query to be "recursive"- meaning, I want all of the data from the referenced tables, not just the values of the foreign keys. However, I don't know what the exact terminology is in order to search through help. Here is an example: (this is exploratory code only. Error handling and imports left out for brevity) http://pastebin.com/HpNB64t4 1. What is the correct terminology for a recursive query, in SQLAlchemy parlance? 2. How do I tell SQL Alchemy to do that? 3. There are two columns in the class which are designated as ForeignKeys. What *should* the ForeignKey() function actually do? I was expecting (not having any background in databases) that this would do the "recursive query) that i"m expecting. However, when I remove ForeignKey() from the class definition, the output does not change at all. I don't understand this. Thanks Tony -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] What is the terminology for ...?
Hi I'm new to databases, SQL, and SQLAlchemy. I've been going through the tutorials and docs at SQLAlchemy.org trying to find a solution to what I believe is a very simple issue with database quiries, however I'm quite uncertain of the terminology. I'm using the declarative form of SQL queries. When doing a query on a table with a foreign key, I want to query the data in the "referenced table". In uncertain terms, I want the query to be "recursive"- meaning, I want all of the data from the referenced tables, not just the values of the foreign keys. However, I don't know what the exact terminology is in order to search through help. Here is an example: (this is exploratory code only. Error handling and imports left out for brevity) http://pastebin.com/HpNB64t4 1. What is the correct terminology for a recursive query, in SQLAlchemy parlance? 2. How do I tell SQL Alchemy to do that? Thanks -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.