Search code examples
pythonsqlflaskpython-elixir

How to perform an "UPDATE" with elixir


I'm using elixir/flask in a small web app I wrote for my own personal aggregator.

I'm trying to create a restful call to mark all items of a particular rssfeed as read.

The SQL statement would look something like UPDATE model_rssitems set hasbeenseen = 1 where rssfeed_id = '%s' % feedid

I don't know how to write the code to make elixir perform that action and when I tried to use session.execute I get an error saying UnboundExecutionError: Could not locate a bind configured on SQL expression or this Session

I'm sure I'm doing something wrong but I can't figure out what.


Solution

  • I assume you haven't used the bind expression yet :)

    Your code requires something like this to tell Elixir what database you're using.

    from elixir import metadata
    metadata.bind = 'sqlite:///your_database_file.sqlite'
    metadata.bind.echo = True