From owner-freebsd-python@freebsd.org Thu Feb 9 17:55:57 2017 Return-Path: Delivered-To: freebsd-python@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3985FCD3611 for ; Thu, 9 Feb 2017 17:55:57 +0000 (UTC) (envelope-from karly@kipshouse.net) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 0BD0B7D9 for ; Thu, 9 Feb 2017 17:55:57 +0000 (UTC) (envelope-from karly@kipshouse.net) Received: by mailman.ysv.freebsd.org (Postfix) id 08598CD3604; Thu, 9 Feb 2017 17:55:57 +0000 (UTC) Delivered-To: python@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 07FD0CD3603 for ; Thu, 9 Feb 2017 17:55:57 +0000 (UTC) (envelope-from karly@kipshouse.net) Received: from mgmt.ironboy.kipshouse.net (ironboy.kipshouse.net [IPv6:2001:470:835a:4242::42]) (using TLSv1.2 with cipher RC4-SHA (128/128 bits)) (Client CN "mx.kipshouse.net", Issuer "Starfield Secure Certificate Authority - G2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id A16527D6 for ; Thu, 9 Feb 2017 17:55:56 +0000 (UTC) (envelope-from karly@kipshouse.net) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kipshouse.org; i=@kipshouse.org; q=dns/txt; s=kh-ss; t=1486662957; x=1518198957; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; z=Date:=20Thu,=209=20Feb=202017=2009:30:04=20-0800|From: =20Karl=20Young=20|To:=20DTD=20|Cc:=20python@FreeBSD.org|Subject:=20Re:=20 MySQLdb=20question|Message-ID:=20<20170209173004.GA2787@m ailboy.kipshouse.net>|References:=20=0D=0A=20<20170126 230225.GV26386@mailboy.kipshouse.net>=0D=0A=20 |MIME-Version:=201.0|In-Reply-To:=20; bh=fdAXVbHMAHi83OkYDUdr0IPaKKCfObK52VY7RFD8Ctk=; b=aQOZAo8bwnn/SIAgAJg/MCZmHwm9aJd3IT/FuYB2UqLnY92YEnlyg60x wMUnD9yex4j35gaIK6YfBWOM1FSjyZ8nBqGu40ZxNcA8c/kwhnFbuBP+l g7qym9kxDh9zHHJF5J8N8yWcH6AUZcav+rrpLwXBE45re41DeqLubdHD6 J4CiHpTrliXMLmWFgrxb3kNdu7Oeb1VZkQKtBCXQDkX7P7MPiSQnu4GoH HDSgnYymSDCxoyRqtUfeqUnc8E5UkeTDOzZf80d45mZYDadgF3Ialh8L2 LPgt3sV5/KEXWaBq583YMiEykCLi9++zfzUZRTkVCw950omIggk0b7Wxr g==; Authentication-Results: d2.ironport.kipshouse.net; dkim=none (message not signed) header.i=none; spf=None smtp.pra=karly@kipshouse.org; spf=None smtp.mailfrom=karly@kipshouse.net; spf=None smtp.helo=postmaster@mailboy.kipshouse.net Received-SPF: None (d2.ironport.kipshouse.net: no sender authenticity information available from domain of karly@kipshouse.org) identity=pra; client-ip=2001:470:835a:1010::26; receiver=d2.ironport.kipshouse.net; envelope-from="karly@kipshouse.net"; x-sender="karly@kipshouse.org"; x-conformance=sidf_compatible Received-SPF: None (d2.ironport.kipshouse.net: no sender authenticity information available from domain of karly@kipshouse.net) identity=mailfrom; client-ip=2001:470:835a:1010::26; receiver=d2.ironport.kipshouse.net; envelope-from="karly@kipshouse.net"; x-sender="karly@kipshouse.net"; x-conformance=sidf_compatible Received-SPF: None (d2.ironport.kipshouse.net: no sender authenticity information available from domain of postmaster@mailboy.kipshouse.net) identity=helo; client-ip=2001:470:835a:1010::26; receiver=d2.ironport.kipshouse.net; envelope-from="karly@kipshouse.net"; x-sender="postmaster@mailboy.kipshouse.net"; x-conformance=sidf_compatible X-SBRS: None X-MID: 235356 X-RemoteIP: 2001:470:835a:1010::26 X-RemoteHost: 2001:470:835a:1010::26, mailboypriv.kipshouse.net X-IronPort-AV: E=McAfee;i="5800,7501,8434"; a="235356" Received: from mailboypriv.kipshouse.net (HELO mailboy.kipshouse.net) ([IPv6:2001:470:835a:1010::26]) by d2.ironport.kipshouse.net with ESMTP; 09 Feb 2017 09:55:56 -0800 Received: by mailboy.kipshouse.net (Postfix, from userid 500) id 246CE44051; Thu, 9 Feb 2017 09:30:05 -0800 (PST) Date: Thu, 9 Feb 2017 09:30:04 -0800 From: Karl Young To: DTD Cc: python@FreeBSD.org Subject: Re: MySQLdb question Message-ID: <20170209173004.GA2787@mailboy.kipshouse.net> References: <20170126230225.GV26386@mailboy.kipshouse.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Arbitrary-Number-Of-The-Day: 42 X-URL: http://www.kipshouse.org/karly X-Work-URL: http://www.cisco.com/ X-Disclaimer: My opinions do not necessarily represent those of my employer. User-Agent: Mutt/1.5.20 (2009-12-10) X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Feb 2017 17:55:57 -0000 DTD(doug@safeport.com)@2017.02.09 11:11:44 -0500: > On Thu, 26 Jan 2017, Karl Young wrote: > > >DTD(doug@safeport.com)@2017.01.26 13:23:56 -0500: > >>I am using py27-MySQLdb-1.2.5 (the default) for FreeBSD 10.3 > >> > >> cmd="update ipv4 set s8='%s',s16='%s',s24='%s' where ip='%s'" % (s8,s16,s24,row[0]) > >> c.execute(cmd) > > > >When you say that it isn't working, I assume you mean it's not updating > >any rows? To see if that's the case, you can assign the return from > >execute and print the result, and print it out. > > > >numrows = c.execute(cmd) > >print numrows > > > >Or use the rowcount attr of the cursor > > > >print c.rowcount > > > >If it's showing 0 rows, try running select where > > > >select * where ip='1.186.248.251 > > > >Is it possible you're connecting to a different host/db than you're > >using for your manual SQL? > > Karl, the issue is InnoDB and perhaps MySQL changes in 5.6.34. Using > the cli autocommit is on by default and using python it is not. A > commit must be done after a series of updates. db.close apparently > does not do a commit. This behavior is somewhat masked in other > program as a select seems to cause the commit to be done. I don't > know if db.close should do a commit or not. > > Thanks again for the response. > > Doug Glad you found the cause, and thanks for posting it. I could see that biting me some time. Look like that's expected behavior, according to this thread:. http://stackoverflow.com/questions/384228/database-does-not-update-automatically-with-mysql-and-python So your choice would be to enable autocommit or always commit before close. Regards -karl > > _____ > Douglas Denault > http://www.safeport.com > doug@safeport.com > Voice: 301-217-9220 > Fax: 301-217-9277 > _______________________________________________ > freebsd-python@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-python > To unsubscribe, send any mail to "freebsd-python-unsubscribe@freebsd.org"