का उपयोग कर पंक्तियों डालने मैं SQLAlchemy के साथ कई पंक्तियों डालने कर रहा हूँ के बाद प्राथमिक कुंजी प्राप्त करें:SQLAlchemy
connection = engine.connect()
topic_res = connection.execute(message_topics.insert(),[
{
'mt_date': time.time(),
'mt_title': title,
'mt_hasattach':u'0',
'mt_starter_id':member.member_id,
'mt_start_time': time.time(),
'mt_last_post_time': time.time(),
'mt_invited_members': u'a:0:{}',
'mt_to_count': u'1',
'mt_to_member_id':member.member_id,
'mt_replies': u'1',
} for member in members ])
topic_res.inserted_primary_key
जब मैं डाला प्राथमिक कुंजी प्राप्त करने की कोशिश, और मैं हो रही है: 'MySQLExecutionContext_mysqldb' वस्तु है:
AttributeError कोई विशेषता 'inserted_primary_key', लेकिन डीबग के कारण topic_res 'ResultProxy' ऑब्जेक्ट है।
तो यदि मैं केवल एक पंक्ति डालता हूं तो मैं topic_res.inserted_primary_key प्राप्त कर सकता हूं।
अच्छे उत्तर हैं, कृपया उनमें से किसी के साथ सहमत हों। – I159