SqlAlchemy and PostgreSql datetime update
I have a PostgreSql table in which I want to update an attribute of type timestamp with timezone (I tried also without timestamp but it does not work). I'm using SqlAlchemy session for that purpose. I fetch an existing record, and update it with a current timestamp: from model import Table from dbconf import session t=session.query(Table).filter(Table.id==1).first() t.available=datetime.now() session.add(t) session.commit() After this command nothing change in the database. What am I doing wrong?
I can assume that you have model of this table, you should add there new update method like this: class table(Base): __tablename__ = 'table' id = Column(Integer, primary_key=True) available = Column(DateTime) asd = Column(Unicode(255)) def update(self, available=None, asd = None): #etc. if available: self.available = available if asd: self.asd = asd and updating happens then like this: import transaction with transaction.manager: t=session.query(Table).filter(Table.id==1).first() #search the object what you want to update t.update(available=datetime.now()) #you can update only one or several cell like this
py2app and xml.etree.ElementTree
What is the difference between isinstance('aaa', basestring) and isinstance('aaa', str)?
Is this essential functional programming feature missing from python?
Hooking into a wave-out on different platforms
What causes subprocess.call to output blank file when attempting db export with mysqldump?
How do I remove something form a list, plus string matching?
Reference to Part of List - Python
Django Delete all but last five of queryset
How do I limit the number of active threads in python?
Calculating the pixel size of a string with Python
Python nested lists and recursion problem
Problems PUTting binary data to Django
How to use long integers in Python to build a range?
Should I use Lex or a home-brewed solution to parse a formula?
Launching default application for given type of file, OS X
Python CGI script IOError Broken Pipe