Exemple #1
0
	def add(self, data):
		"insert new record"
		n = len(data)
		if n <= 0:
			return False
		dk = data.keys()
		s = 'INSERT INTO ' + _tblname + '(' + ','.join(dk) + ') VALUES(' + ','.join(['?']*n) + ')'
		v = tuple([data[k] for k in dk])
	
		_curs.execute(s, v)
		_conn.commit()

		return True
Exemple #2
0
    def add(self, data):
        "insert new record"
        n = len(data)
        if n <= 0:
            return False
        dk = data.keys()
        s = 'INSERT INTO ' + _tblname + '(' + ','.join(
            dk) + ') VALUES(' + ','.join(['?'] * n) + ')'
        v = tuple([data[k] for k in dk])

        _curs.execute(s, v)
        _conn.commit()

        return True
Exemple #3
0
	def modify(self, data, cond = {'1':'1'}):
		"modify by condition"
		n = len(data)
		if n <= 0:
			return False
		dk = data.keys()
		ck = cond.keys()
		s = 'UPDATE ' + _tblname + ' SET ' + ','.join([k + '=?' for k in dk]) \
			+ ' WHERE ' + ','.join([k + '=?' for k in ck])
		v = tuple([data[k] for k in dk] + [cond[k] for k in ck])
		
		_curs.execute(s, v)
		_conn.commit()

		return True
Exemple #4
0
    def modify(self, data, cond={'1': '1'}):
        "modify by condition"
        n = len(data)
        if n <= 0:
            return False
        dk = data.keys()
        ck = cond.keys()
        s = 'UPDATE ' + _tblname + ' SET ' + ','.join([k + '=?' for k in dk]) \
         + ' WHERE ' + ','.join([k + '=?' for k in ck])
        v = tuple([data[k] for k in dk] + [cond[k] for k in ck])

        _curs.execute(s, v)
        _conn.commit()

        return True