title: Sqlalchemy, postgres datetime without timezone
body: <p>I am trying to add timezone support to a python/sqlalchemy script. I have studied timezones and use pytz. I understand I should do as much as possible in UTC and only display local times. Due to the nature of the application, this is very easy. </p>
  
  <p>Everything works, except that when I insert UTC data, it gets somehow converted to local time (BST) before entering the database, and I am completely lost why this happens and how I can avoid it. </p>
  
  <p>My table (postgres) is defined as follows (relevant part only):</p>
  
  <pre><code>fpp=&gt; \d foo;
                                       Table "public.foo"
    Column   |            Type             |                              Modifiers                          
  -----------+-----------------------------+-------------------------------------------------------------
   x         | integer                     | 
   y         | integer                     | 
   when_utc  | timestamp without time zone | 
  </code></pre>
  
  <p>I have debugged sqlalchemy when it does an insert. This is what happens:</p>
  
  <pre><code>2016-07-28 17:16:27,896 INFO sqlalchemy.engine.base.Engine INSERT INTO 
    foo (x, y, "when_utc") VALUES (%(x)s, %(y)s, %(when_utc)s) RETURNING fb_foo.id
  
  2016-07-28 17:16:27,896 INFO sqlalchemy.engine.base.Engine {
    'when_utc': datetime.datetime(2016, 7, 11, 23, 0, tzinfo=&lt;UTC&gt;), 'y': 0, 'x': 0}
  </code></pre>
  
  <p>So it inserts in UTC 11/7/2016 23:00:00. When I query it in command line psql, this is what I find:</p>
  
  <pre><code>fpp=&gt; select x,y,when_utc from foo;
   x | y |      when_utc       
  ---+---+---------------------
   0 | 0 | 2016-07-12 00:00:00
  (1 row)
  </code></pre>
  
  <p>What is going on? I am adamant nothing modifies the field in between. It just seems to add the DST hour to my database entry. Why? How can I avoid this?  </p>
  
  <p>R</p>