Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: GeoIP revisited

by erix (Parson)
on Nov 23, 2018 at 15:53 UTC ( #1226235=note: print w/replies, xml ) Need Help??

in reply to GeoIP revisited

Just a thought: you could insert a 'IF NOT EXISTS'-create just before the TRUNCATE-statement so that the program 'Just Works' if the table isn't there.

$dbh->do(" CREATE TABLE IF NOT EXISTS geoip ( netblock cidr NOT NULL, country_code text NOT NULL, country_name text NOT NULL, CONSTRAINT geoip_pk PRIMARY KEY (netblock) );" ) or die($dbh->errstr);

IF NOT EXISTS was added to CREATE TABLE long ago and all supported versions of postgres support it.

(I removed the oids- and tablespace-stuff, as I didn't need that.)

Replies are listed 'Best First'.
Re^2: GeoIP revisited
by cavac (Curate) on Nov 27, 2018 at 14:04 UTC

    Good catch. A lot of other tables in my database already have triggers that access the geoip table (productive system with a slight dose of feature creep), so i never thought of adding the table creation into this script...

    perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1226235]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-07-08 11:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found