I'm having difficulty writing what should be a simple SQL update statement in SQLAlchemy Core. However, I cannot find documentation, examples, or manuals that show how to combine several conditions. I am sure that he is there - he simply cannot find him.
Here is the table:
self.struct = Table('struct', metadata, Column('schema_name', String(40), nullable=False, primary_key=True), Column('struct_name', String(40), nullable=False, primary_key=True), Column('field_type', String(10), nullable=True), Column('field_len', Integer, nullable=True) )
Here's the insert and update instruction:
def struct_put(self, **kv): try: i = self.struct.insert() result = i.execute(**kv) except exc.IntegrityError:
The code handles the insertion in order, but updates all the rows in the table. Can you help me understand the syntax of this where clause? All suggestions are welcome - in advance.
EDIT: The corrected sentence is as follows:
where((and_(self.struct.c.parent_struct_name==kv['parent_struct_name'], self.struct.c.struct_name==kv['struct_name'], self.struct.c.schema_name==kv['schema_name']))).\
This is a very simple syntax, but given the many levels of SQLAlchemy, it was unexpectedly difficult to determine what exactly applies in this context.