How to do exclude query by python sqlalchemy

The

database is mysql, checked the document and found no exclude, only an except_.
if my table is called table_a, and has a status field, if it is a single field, you can use! = to exclude,
what should I say if it is a scope? For example, if you have a field date, to query all records that are not in a certain time range, you can do this

in the time range.

from datetime import datetime
table_a.query.filter(table_a.date.between(datetime.now()-datetime.timedelta(hours=2), now)))

the above code queries the data from the current time to 2 hours ago. How do I write if I want to query all the data outside this range?
under the guidance of the bosses.

Mar.15,2021

use NOT BETWEEN . Please refer to SQL syntax, https://www.w3schools.com/sql.

.
MyModel.query.filter(sqlalchemy.not_(Mymodel.name.between(1, 100)))

-sharp  SYMMETRIC  a > b  a < b
MyModel.query.filter(sqlalchemy.not_(Mymodel.name.between(a, b, symmetric=True)))

all right, thank you


sql to sqlachemy project , you deserve to see

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b227f2-2ae6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b227f2-2ae6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?