Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Kevin Waterson
This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: I suspect that you might find these blocks to be networks and subnets and consequently identified by the octets in the dotted IP. yes, they would be nets and subnets. But how to identify them or single out a net/subnet? Kind

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Trevor Talbot
On 12/4/06, Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: I suspect that you might find these blocks to be networks and subnets and consequently identified by the octets in the dotted IP. yes, they would be nets and subnets. But

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Kevin Waterson
This one time, at band camp, Trevor Talbot [EMAIL PROTECTED] wrote: I'd store the IPs in the DB in integer form as Lloyd suggested, if range queries are your goal. Do conversion to and from display format in the application. Yes, they are stored as INTEGER. and the conversion outside

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Lloyd
I feel little difficulty in understanding what you actually want (I thing the same is for all...). So could make it more clear? so that your problem can be solved fast! Thanks, Lloyd. Yes, they are stored as INTEGER. and the conversion outside sqlite is simple. However, I still need to

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread John Stanton
Kevin Waterson wrote: This one time, at band camp, Trevor Talbot [EMAIL PROTECTED] wrote: I'd store the IPs in the DB in integer form as Lloyd suggested, if range queries are your goal. Do conversion to and from display format in the application. Yes, they are stored as INTEGER. and the

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Kevin Waterson
This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: You can add a custom function which calls the dotted IP to IP function. yeah, thats what I was hoping to avoid. So, my solution is to use awk to snarf the IP addresses from csv file before import and the convert to long IP and

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Nicolas Williams
On Tue, Dec 05, 2006 at 08:21:35PM +1100, Kevin Waterson wrote: This one time, at band camp, Trevor Talbot [EMAIL PROTECTED] wrote: I'd store the IPs in the DB in integer form as Lloyd suggested, if range queries are your goal. Do conversion to and from display format in the

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Dennis Cote
Kevin Waterson wrote: well, the range could be 256, or 16, or 131072 or 2048 or any other number really. but the IP will always be a valid IPv4 address. Given a valid IPv4 address, I wish to find the range it falls into. eg: SELECT * FROM table WHERE start 203.7.136.123 AND 203.7.136.123

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Nicolas Williams
On Tue, Dec 05, 2006 at 09:58:02AM -0700, Dennis Cote wrote: select case when substr(ip, 2, 1) = '.' then -- one digit first quad case when substr(ip, 4, 1) = '.' then -- 1 digit second quad case when substr(ip, 6, 1) = '.' then -- 1 digit third

[sqlite] Re: Re: ip2long

2006-12-04 Thread Igor Tandetnik
Kevin Waterson [EMAIL PROTECTED] wrote: This one time, at band camp, Igor Tandetnik [EMAIL PROTECTED] wrote: How is the range specified? In the database the IP is 1.2.3.4 and the range is eg: 65536 I don't quite understand. To continue your example, exactly which IP addresses are

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread Lloyd
The way I am dealing with this is... First convert the IP to a 32bit integer. (In the system it will represented as a 32bit integer) Store it in the database. Perform the comparison operations on this stored data. Thanks, Lloyd On Mon, 2006-12-04 at 22:07 -0500, Igor Tandetnik wrote: Kevin

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread Kevin Waterson
This one time, at band camp, Igor Tandetnik [EMAIL PROTECTED] wrote: I don't quite understand. To continue your example, exactly which IP addresses are considered to fall into the range 65536? How do you figure 1.2.3.4 is in this range, if indeed it is? The begging IP may be 81.163.0.0 with

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread John Stanton
Kevin Waterson wrote: This one time, at band camp, Igor Tandetnik [EMAIL PROTECTED] wrote: I don't quite understand. To continue your example, exactly which IP addresses are considered to fall into the range 65536? How do you figure 1.2.3.4 is in this range, if indeed it is? The begging IP

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread Kevin Waterson
This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: It looks as if you are looking to see if an address belongs to a particular class B network. Are all your searches done that way? If they are you may be able to use a regular expression to do your search. well, the range

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread John Stanton
Kevin Waterson wrote: This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: It looks as if you are looking to see if an address belongs to a particular class B network. Are all your searches done that way? If they are you may be able to use a regular expression to do your

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread Kevin Waterson
This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: Are you actually searching for membership in a class A, B or C network or perhaps a subnet? If you are you can use the dotted format to your advantage. No, The search is for which registry owns the block of IPs the that the

Re: [sqlite] Re: Re: ip2long

2006-12-04 Thread John Stanton
Kevin Waterson wrote: This one time, at band camp, John Stanton [EMAIL PROTECTED] wrote: Are you actually searching for membership in a class A, B or C network or perhaps a subnet? If you are you can use the dotted format to your advantage. No, The search is for which registry owns the