Dear All, I want to do something like this:
(MachineExists,), = session.query(exists().where(Machine.name.like('%'+machine+'%'))) if not MachineExists: print("Specify machine name better") return m = session.query(Machine.name).filter(Machine.name.like('%'+machine+'%')).one() print("Machine is: "+m.name ) machine = m.name gData = GeneralMeasurementData(datapath= datafilename,datatype="SilverMasses" ) gData.machine = m <---- this is where it fails.. ...... session.add(gData) session.commit() gData has a foreign key on Machine.id. It seems m is not a Machine object. I think it should be clear what I want to do, but I can't figure what the SQLAlchemy way would be to do it.... Is there a way to do this??? Best Simon -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.