Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition.

I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition.

Scheduled Pinned Locked Moved Uncategorized
pythonsqlalchemy
2 Posts 2 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • encthenet@flyovercountry.socialE This user is from outside of this forum
    encthenet@flyovercountry.socialE This user is from outside of this forum
    encthenet@flyovercountry.social
    wrote last edited by
    #1

    I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition. It is likely that SQLAlchemy is caching something, even though the session is fresh,

    But the query is:
    stmt = select(orm.Files).where(orm.Files.user == user and orm.Files.ontape == False).limit(1)

    and it's returning:
    Files(user='someuser', uuid='1b9f0805-6587-46ba-a44d-df0e2a1654bb', name='filename', size=3181952, ontape=True)

    NEVER EVER should database software cache data at the start of a session. That's just wrong.

    #Python #SQLAlchemy

    stiiin@infosec.spaceS 1 Reply Last reply
    0
    • encthenet@flyovercountry.socialE encthenet@flyovercountry.social

      I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition. It is likely that SQLAlchemy is caching something, even though the session is fresh,

      But the query is:
      stmt = select(orm.Files).where(orm.Files.user == user and orm.Files.ontape == False).limit(1)

      and it's returning:
      Files(user='someuser', uuid='1b9f0805-6587-46ba-a44d-df0e2a1654bb', name='filename', size=3181952, ontape=True)

      NEVER EVER should database software cache data at the start of a session. That's just wrong.

      #Python #SQLAlchemy

      stiiin@infosec.spaceS This user is from outside of this forum
      stiiin@infosec.spaceS This user is from outside of this forum
      stiiin@infosec.space
      wrote last edited by
      #2

      @encthenet I don't think you can use Python's own `and` and `or` operators. I seem to remembee that that won't work as expected, and the manual doesn't mention their use. Either make two chained `.where()` calls, or import and use `and_()` and `or_()`.

      Link Preview Image
      Using SELECT Statements — SQLAlchemy 2.0 Documentation

      favicon

      (docs.sqlalchemy.org)

      1 Reply Last reply
      1
      0
      • R relay@relay.infosec.exchange shared this topic
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups