sqlalchemy intersect错误

stszievb  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(281)

user1 = User(username='john') user2 = User(username='jim') user1.intersect(user2).all() 使用mariadb时抛出错误,但与sqlite不一起使用。
错误如下:
sqlalchemy.exc.programmingerror:(\u mysql\u exceptions.programmingerror)(1064,“您的sql语法有错误;请查看与您的mysql服务器版本对应的手册,以获取正确的语法,使用第4行的“intersect select user.id as user\u id,user.username as user\u username,user.email”[sql:“select anon\u 1.user\u id as anon\u 1 user\u id,anon\u 1.user\u username as anon\u 1 user\u username,anon\u 1.user\u email as anon\u 1 user\u email,Anonu 1.user\u password作为Anonu 1\u user\u password,Anonu 1.user\u first\u name作为Anonu 1\u user\u first\u name,Anonu 1.user\u last\u name作为Anonu 1\u user\u last\u name,Anonu 1.user\u about\u me作为Anonu 1\u user\u about\u me,Anonu 1.user\u last\u seen作为Anonu 1\u user\u last\u seen,Anonu 1.user\u member\u since作为Anonu 1\u user\u member\u since,anon\u 1.user\u last\u message\u read\u time as anon\u 1\u user\u last\u message\u read\u time,anon\u 1.user\u last\u request\u read\u time as anon\u 1\u user\u last\u request\u read\u time from(选择user.id作为user\u id,user.username作为user\u username,user.email作为user\u email,user.password作为user\u password,user.first\u name作为user\u last\u name,user.about\u me as user\u about\u me,user.last\u seen as user\u last\u seen,user.member\u since as user\u member\u since,user.last\u message\u read\u time as user\u last\u message\u read\u time,user.last\u request\u read\u time as user\u last\u request\u read\u time from user,友谊\n其中friendships.user\u id=%s和friendships.friend\u id=user.id相交选择user.id作为user\u id,user.username作为user\u username,user.email作为user\u email,user.password作为user\u password,user.first\u name作为user\u first\u name,user.last\u name作为user\u last\u name,user.about\me作为user\u about\me,user.last\u作为user\u last\u seen,user.member\u-since as user\u-member\u-since,user.last\u-message\u-read\u-time as user\u-last\u-message\u-read\u-time,user.last\u-request\u-read\u-time as user\u-last\u-request\u-read\n from user,friendships\nwhere friendships.user\u id=%s and friendships.friends\u id=user.id)as anon\u 1'][参数:(1,2)](此错误的背景位于:http://sqlalche.me/e/f405)

ycggw6v2

ycggw6v21#

mysql不支持intersect。sqlite有。mariadb从10.3版开始执行。

相关问题