I am having an issue with placing the right qoutes in the following sqlite statement , which places the customer id(c_id) , a primary key of customers table , into the foreign key c_id of place table.
I could extract the c_id by un-nesting the code , and executing the portion 'select c_id from customers where fname =?" separately . However I want more conciseness in my code .
t = (fname,)
place = (postal_code , place_name)
cur.execute(""insert into place(postal_code ,place_name,c_id) values(?,?,("select c_id from customers where fname =?"),t)""",place)
The quotes are all out of place , help is appreciated for a fix .
Btw: This question is a similar duplicate of this question Insert Data Into Tables Linked by Foreign Key , from which I copied the idea of nesting .