0
我使用TxPostgres的行插入PostgreSQL的回報,我的存儲過程是txpostgres最後插入從存儲過程
CREATE OR REPLACE FUNCTION gps_open_connection(
_ip character varying(15),
_port integer
) RETURNS integer AS $$
DECLARE
log_id integer;
BEGIN
INSERT INTO gpstracking_device_logs (gpstracking_device_logs.id, gpstracking_device_logs.ip, gpstracking_device_logs.port, gpstracking_device_logs.status, gpstracking_device_logs.created, gpstracking_device_logs.updated) VALUES (DEFAULT, _ip, _port, TRUE, NOW(), NOW()) RETURNING id INTO log_id;
END
$$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER;
與此存儲過程從一個方法在扭曲類叫,我的方法是
def openConnection (self, ip, port):
self.connection['ip'] = ip
self.connection['port'] = port
self.connection['status'] = True
self._d.addCallback(lambda _: self._conn.runQuery("select gps_open_connection('%s', '%s')" % (ip, port)))
self.id ?
我的問題是,我不知道如何來填充self.id,我希望你能幫助在這個問題上