q = session.query(Table1.field1, Table1.field2)\
.outerjoin(Table2)\ # use in case you have relationship defined
# .outerjoin(Table2, Table1.id == Table2.table_id)\ # use if you do not have relationship defined
.filter(Table2.tbl2_id == None)
should do it, assuming that field1
and field2
are from Table1
, and that you define a relationship:
class Table2(Base):
# ...
table1 = relationship(Table1, backref="table2s")
Related Contents:
- How to execute raw SQL in Flask-SQLAlchemy app
- How do I get a raw, compiled SQL query from a SQLAlchemy expression?
- sqlalchemy: how to join several tables by one query?
- Python, SQLAlchemy pass parameters in connection.execute
- SQLAlchemy: how to filter date field?
- How to use variables in SQL statement in Python?
- Writing a connection string when password contains special characters
- Pandas read_sql with parameters
- Difference between filter and filter_by in SQLAlchemy
- Speeding up pandas.DataFrame.to_sql with fast_executemany of pyODBC
- Using OR in SQLAlchemy
- Sqlite / SQLAlchemy: how to enforce Foreign Keys?
- Pandas DENSE RANK
- How to create a large pandas dataframe from an sql query without running out of memory?
- How to put parameterized sql query into variable and then execute in Python?
- Passing table name as a parameter in psycopg2
- Flask SQLAlchemy query, specify column names
- Query for list of attribute instead of tuples in SQLAlchemy
- SQLAlchemy: What’s the difference between flush() and commit()?
- How to give column name dynamically from string variable in sql alchemy filter?
- Debugging (displaying) SQL command sent to the db by SQLAlchemy
- How to disable SQLAlchemy caching?
- Case Insensitive Flask-SQLAlchemy Query
- How to upsert pandas DataFrame to Microsoft SQL Server table?
- SQLAlchemy ORDER BY DESCENDING?
- SQL Alchemy ORM returning a single column, how to avoid common post processing
- How to log all sql queries in Django?
- Flask-SQLalchemy update a row’s information
- pyodbc – How to perform a select statement using a variable for a parameter
- Get inserted key before commit session
- Serve image stored in SQLAlchemy LargeBinary column
- How do I execute inserts and updates in an Alembic upgrade script?
- How to create a new database using SQLAlchemy?
- Generate sql with subquery as a column in select statement using SQLAlchemy
- How to do an upsert with SqlAlchemy?
- SQLAlchemy ManyToMany secondary table with additional fields
- LEFT JOIN Django ORM
- How do I select literal values in an sqlalchemy query?
- Python Pandas write to sql with NaN values
- Python SQL query string formatting
- How can I profile a SQLAlchemy powered application?
- Python call sql-server stored procedure with table valued parameter
- sqlalchemy.exc.NoSuchModuleError: Can’t load plugin: sqlalchemy.dialects:postgres
- Strange SQLAlchemy error message: TypeError: ‘dict’ object does not support indexing
- SqlAlchemy – Filtering by Relationship Attribute
- group by year, month, day in a sqlalchemy
- How to perform OR condition in django queryset?
- Getting first row from sqlalchemy
- How to build many-to-many relations using SQLAlchemy: a good example
- How do I INSERT INTO t1 (SELECT * FROM t2) in SQLAlchemy?