Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: GeoIP revisited

by erix (Prior)
on Nov 23, 2018 at 15:53 UTC ( [id://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 (Parson) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found