Thanks for your reply and offer to help. I am able to create an Engine and 
connect to the MySQL db. I can execute simple sql queries although I wasn't 
able to get the query I posted to work due to a syntax error (probably 
having to do with the quotes). I have not mapped any tables to classes.

On Sunday, August 18, 2019 at 8:54:57 PM UTC-4, Peter Schutt wrote:
>
> Hi Ira, I'd be happy to help you find your feet with the SQLAlchemy ORM.
>
> In general when creating an application that uses the SQLAlchemy ORM, you 
> would start with an Engine (for connecting to the db), a declarative base 
> class (maps db table to python class) and a Session instance (for using a 
> connection to issue queries). Do you have any familiarity with those 
> concepts?
>
>
> On Monday, 19 August 2019 02:34:05 UTC+10, Ira Fuchs wrote:
>>
>> I am new to sqlalchemy and I would like to begin using it to create 
>> scripts with some sql queries that I have been using but need to change 
>> from time to time. It would help a lot if someone could translate one of 
>> these queries to python sqlalchemy using an ORM (not simply executing the 
>> query as is) so that I could use this as a template for other queries, or 
>> at least learn from it.
>>
>> One of my queries looks like this:
>>
>> SELECT DISTINCT last_name, first_name, street_address, city, a.name, 
>> postal_code, f.name as country FROM db_contact c, db_entity_tag d , 
>> db_address e, db_state_province a, db_country f WHERE c.id = d.entity_id 
>> and tag_id = 6 and c.id = e.contact_id AND state_province_id = a.id  and 
>> e.country_id = f.id and  display_name not in ( SELECT display_name FROM 
>> db_contribution, db_contact c, db_entity_tag d WHERE receive_date > 
>> '2005-07-01' and contact_id = c.id and c.id = entity_id and tag_id = 6 )
>>
>> Thanks for any help.
>>
>>

-- 
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  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/12fc9f74-893d-4e7d-98be-1e4545899625%40googlegroups.com.

Reply via email to