Date: Thu, 9 Feb 2017 09:30:04 -0800 From: Karl Young <karly@kipshouse.org> To: DTD <doug@safeport.com> Cc: python@FreeBSD.org Subject: Re: MySQLdb question Message-ID: <20170209173004.GA2787@mailboy.kipshouse.net> In-Reply-To: <alpine.BSF.2.00.1702091045250.13043@bucksport.safeport.com> References: <alpine.BSF.2.00.1701261321410.15335@bucksport.safeport.com> <20170126230225.GV26386@mailboy.kipshouse.net> <alpine.BSF.2.00.1702091045250.13043@bucksport.safeport.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170209173004.GA2787>