Archive for December, 2009
XE currency feed imports w/PostgreSQL
Dec 10th
This table and trigger will facilitate periodic currency updates (ie: race condition free) from XE feeds for a single base currency. In this case, USD.
CREATE TABLE currency_feed
(
currency character(3) NOT NULL,
country character varying NOT NULL,
from_usd double precision NOT NULL,
to_usd double precision NOT NULL,
CONSTRAINT currency_feed_pkey PRIMARY KEY (currency)
)
WITH (
OIDS=FALSE
);
ALTER TABLE currency_feed OWNER TO postgres;
-- this trigger replicates the 'on duplicate key update' mysql directive
CREATE FUNCTION repl_currency() RETURNS trigger AS $BODY$
BEGIN
IF (EXISTS(SELECT 1 FROM "currency_feed" C WHERE C."currency" = NEW."currency")) THEN
UPDATE "currency_feed" SET "from_usd" = NEW."from_usd", "to_usd" = NEW."to_usd" WHERE "currency" = NEW."currency";
RETURN OLD;
ELSE
RETURN NEW;
END IF;
END;
$BODY$ LANGUAGE plpgsql;
ALTER FUNCTION repl_currency() OWNER TO postgres;
CREATE TRIGGER repl_currency BEFORE INSERT ON "currency_feed" FOR EACH ROW EXECUTE PROCEDURE repl_currency();
Periodic import is then just :
set client_encoding to 'ISO-8859-1'; copy currency_feed from '/path/to/feed.csv' delimiter ',' csv quote as '"';
… fast falling in love with Postgres
Weelya releases Ajax Push Engine 1.0
Dec 9th
Weelya, an interesting realtime web startup from France, has released version 1.0 of it’s Ajax Push Engine (APE). press release here. Currently chats back to APE server over its own protocol, with WebSocket and lovely HTML5 server-sent events support not too far away – keep an eye on this one.
In other news, Chromium Websockets support is go!!.
Finally, it looks like comet/long polling/nph hacks will be kicked to the curb and not a moment too soon – 2010 is setting up to be a paradigm shift year. yay.


Recent Comments