WebFaction
Community site: login faq

I have a flask website set up with mod_wsgi and SQLAlchemy.

My application db works perfectly on my local machine. On the remote server, I am able to read the db successfully only when I access it from the shell through the SQLAlchemy API. My mod_wsgi app is not reading the database correctly, though.

This is on the remote server python shell:

>>> if Job.query.filter(Job.date == date.today()).first():
...     print('yay, i found search results!')
... 
yay, i found search results!

Here is the (simplified) chunk of code in my flask views.py file that is functioning locally, but not on the remote server (notice that the SQL query is exactly the same as the one executed on the remote python shell):

# today's job if it exists
if Job.query.filter(Job.date == date.today()).first():  # today could be none
    return '<p>There is kitchen duty today</p>'
else:
    return '<p>No kitchen duty today!</p>'

Locally, accessing the URL that maps to this view shows the HTML

There is kitchen duty today!

On my remote server, the HTML

No kitchen duty today!

shows up, even though that same expression is not None when queried through the remote python shell.

This leads me to believe that the WSGI server that is running my flask app is not reading the SQLAlchemy db correctly.

A few observations I've made/relevant information:

I would greatly appreciate any help here. Thank you!

asked 07 May '15, 06:56

lnaran
113
accept rate: 0%


After checking the support ticket that you submitted concurrently with this question, it looks like this may have been a simple matter of code not being reloaded. Restarting your mod_wsgi Apache instance seems to have resolved it.

permanent link

answered 07 May '15, 17:29

seanf
12.2k41836
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×55
×44
×6

question asked: 07 May '15, 06:56

question was seen: 1,775 times

last updated: 07 May '15, 17:29

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM