comparison roundup/backends/back_mysql.py @ 5381:0942fe89e82e

Python 3 preparation: change "x.has_key(y)" to "y in x". (Also likewise "not in" where appropriate.) Tool-generated patch.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 22:08:17 +0000
parents 35ea9b1efc14
children 0db3779702d9
comparison
equal deleted inserted replaced
5380:64c4e43fbb84 5381:0942fe89e82e
47 , 'serializable': 'SERIALIZABLE' 47 , 'serializable': 'SERIALIZABLE'
48 } 48 }
49 49
50 def connection_dict(config, dbnamestr=None): 50 def connection_dict(config, dbnamestr=None):
51 d = rdbms_common.connection_dict(config, dbnamestr) 51 d = rdbms_common.connection_dict(config, dbnamestr)
52 if d.has_key('password'): 52 if 'password' in d:
53 d['passwd'] = d['password'] 53 d['passwd'] = d['password']
54 del d['password'] 54 del d['password']
55 if d.has_key('port'): 55 if 'port' in d:
56 d['port'] = int(d['port']) 56 d['port'] = int(d['port'])
57 return d 57 return d
58 58
59 def db_nuke(config): 59 def db_nuke(config):
60 """Clear all database contents and drop database itself""" 60 """Clear all database contents and drop database itself"""
250 250
251 # figure actions based on data type 251 # figure actions based on data type
252 for name, s_prop in old_spec[1]: 252 for name, s_prop in old_spec[1]:
253 # s_prop is a repr() string of a hyperdb type object 253 # s_prop is a repr() string of a hyperdb type object
254 if s_prop.find('Multilink') == -1: 254 if s_prop.find('Multilink') == -1:
255 if properties.has_key(name): 255 if name in properties:
256 propnames.append(name) 256 propnames.append(name)
257 continue 257 continue
258 tn = '%s_%s'%(cn, name) 258 tn = '%s_%s'%(cn, name)
259 259
260 if properties.has_key(name): 260 if name in properties:
261 # grabe the current values 261 # grabe the current values
262 sql = 'select linkid, nodeid from %s'%tn 262 sql = 'select linkid, nodeid from %s'%tn
263 self.sql(sql) 263 self.sql(sql)
264 rows = self.cursor.fetchall() 264 rows = self.cursor.fetchall()
265 265
266 # drop the old table 266 # drop the old table
267 self.drop_multilink_table_indexes(cn, name) 267 self.drop_multilink_table_indexes(cn, name)
268 sql = 'drop table %s'%tn 268 sql = 'drop table %s'%tn
269 self.sql(sql) 269 self.sql(sql)
270 270
271 if properties.has_key(name): 271 if name in properties:
272 # re-create and populate the new table 272 # re-create and populate the new table
273 self.create_multilink_table(klass, name) 273 self.create_multilink_table(klass, name)
274 sql = '''insert into %s (linkid, nodeid) values 274 sql = '''insert into %s (linkid, nodeid) values
275 (%s, %s)'''%(tn, self.arg, self.arg) 275 (%s, %s)'''%(tn, self.arg, self.arg)
276 for linkid, nodeid in rows: 276 for linkid, nodeid in rows:

Roundup Issue Tracker: http://roundup-tracker.org/