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

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

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: > 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

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

Re: [sqlite] ip2long

2006-12-04 Thread Jim Dodgen
I would break each octet into separate fields then compare octet by octet Kevin Waterson wrote: How can I SELECT an IP within a range? All my IP's are stored as 1.2.3.4 but I need to check if each is within a range of long IP's. Can this be done with SQLite? or do I need some sort of external

Re: [sqlite] Re: Re: Re: ip2long

2006-12-04 Thread Kevin Waterson
This one time, at band camp, "Igor Tandetnik" <[EMAIL PROTECTED]> wrote: > ip between '81.163.0.0' and '81.163.999.999' This would require me know the value of the range before selecting. The addittion of the IP plus the range is what gets me. How to go about it? Kind regards Kevin --

[sqlite] Re: 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: 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

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

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

[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: ip2long

2006-12-04 Thread Kevin Waterson
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 Kind regards Kevin -- "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb

[sqlite] Re: Re: Deleting rows with duplicate in one field

2006-12-04 Thread Igor Tandetnik
RB Smissaert <[EMAIL PROTECTED]> wrote: Thanks, that works. Couldn't get it to work with an alias t1: delete from table1 t1 where exists ( select * from table1 t2 where t1.fieldB = t2.fieldB and t1.OID <> t2.OID Any what is wrong with that? It's not a valid syntax for DELETE statement.

[sqlite] Re: ip2long

2006-12-04 Thread Igor Tandetnik
Kevin Waterson <[EMAIL PROTECTED]> wrote: How can I SELECT an IP within a range? All my IP's are stored as 1.2.3.4 but I need to check if each is within a range of long IP's. How is the range specified? Igor Tandetnik

[sqlite] ip2long

2006-12-04 Thread Kevin Waterson
How can I SELECT an IP within a range? All my IP's are stored as 1.2.3.4 but I need to check if each is within a range of long IP's. Can this be done with SQLite? or do I need some sort of external ip2long() function to throw at it? Kind regards kevin -- "Democracy is two wolves and a lamb

RE: [sqlite] Re: Deleting rows with duplicate in one field

2006-12-04 Thread RB Smissaert
Thanks, that works. Couldn't get it to work with an alias t1: delete from table1 t1 where exists ( select * from table1 t2 where t1.fieldB = t2.fieldB and t1.OID <> t2.OID Any what is wrong with that? Also it is a bit slow despite an index of fieldB. Any ideas how to speed this up? RBS

[sqlite] Re: Deleting rows with duplicate in one field

2006-12-04 Thread Igor Tandetnik
RB Smissaert <[EMAIL PROTECTED]> wrote: Trying to delete rows in a SQLite table where One particular field has a duplicate value. Tried this query, using a self-join: DELETE FROM table1 t1 INNER JOIN table1 t2 ON (t1.fieldB = t2.fieldB) WHERE t1.OID <> t2.OID But I get an error near t1

[sqlite] Deleting rows with duplicate in one field

2006-12-04 Thread RB Smissaert
Trying to delete rows in a SQLite table where One particular field has a duplicate value. Tried this query, using a self-join: DELETE FROM table1 t1 INNER JOIN table1 t2 ON (t1.fieldB = t2.fieldB) WHERE t1.OID <> t2.OID But I get an error near t1 Any suggestion what I am doing wrong here? RBS

RE: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread RB Smissaert
> You might want to check the records for the patients with DOB > before 1900-01-01 Already taken care of that long time ago. As said, I am more familiar with Excel than with SQLite, but catching up. RBS -Original Message- From: Dennis Cote [mailto:[EMAIL PROTECTED] Sent: 04 December

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Dennis Cote
RB Smissaert wrote: I am dealing with a clinical (patients) database and there are only 8 patients with a date of birth before 1900-02-28, so not a major problem. Clinical data is all well after that. I will see what the speed penalty is from doing the when then else and if it is small then

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread John Stanton
It is a very common algorithm. From memory it is implemenented in Sqlite, for example. [EMAIL PROTECTED] wrote: can convert to seconds since start of epoch, do the arithmetic, then convert back Don't get you. It would be quite a calculation, with leap years etc. RBS On Sun, Dec 03,

Re: [sqlite] is blob compression worth it

2006-12-04 Thread John Stanton
What are you using for compression? Have you checked that you get a useful degree of compression on that numeric data? You might find that it is not particularly amenable to compression. Hickey, Larry wrote: I have a blob structure which is primarily doubles. Is there anyone with some

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread John Stanton
They are in the same format as Interbase dates. Could there be a schema error and they have been wrongly identified? Can you transfer them to be ing correct date types in Interbase, then you just use very conventional tools for your transfer? [EMAIL PROTECTED] wrote: Well, these fields I

RE: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread RB Smissaert
I am dealing with a clinical (patients) database and there are only 8 patients with a date of birth before 1900-02-28, so not a major problem. Clinical data is all well after that. I will see what the speed penalty is from doing the when then else and if it is small then apply it to the date of

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Dennis Cote
[EMAIL PROTECTED] wrote: Great stuff. For your information it needs to be: julianday('1899-12-30') Yes, that will accomplish the same thing. There are really two issues, the fact that excel uses 1 (not 0) as the serial number for 1900-01-01, and the fact that it incorrectly assumes

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
course, I get it. >> Haven't got it working though. Still the invalid use of null error. >> >> > Bart, > > Here is what I get: > > SQLite version 3.3.5 > Enter ".help" for instructions > sqlite> select > ...>

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
; Even more reason to use the original substring based version. > > select > cast ( > julianday( > cast(20061204 / 10000 as integer) || '-' || > substr('00' || (cast(20061204 / 100 as integer) % 100), -2, > 2) || '-' || >

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
Hi Dennis, Got this working now, great stuff and thanks! Will do some testing to see what is faster and report back here. RBS > [EMAIL PROTECTED] wrote: >> Thanks , will try that. >> What is as excel_date? >> Is this a variable or is this jus plain SQL against SQLite? >> >> > Bart, > >

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Dennis Cote
, but the numeric calculations don't insert leading zeros for months and days less than 10. Here i sa modified version that does leading zero insertion. Even more reason to use the original substring based version. select cast ( julianday( cast(20061204 / 1 as integer

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
> just a normal SQL alias name Of course, I get it. Haven't got it working though. Still the invalid use of null error. RBS > [EMAIL PROTECTED] wrote: >> Thanks , will try that. >> What is as excel_date? >> Is this a variable or is this jus plain SQL against SQLite? >> >> > Bart, > >

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
> can convert to seconds since start of epoch, do the arithmetic, > then convert back Don't get you. It would be quite a calculation, with leap years etc. RBS > On Sun, Dec 03, 2006 at 05:31:55PM +, RB Smissaert wrote: >> Still have the problem though how to compare dates in SQLite when the

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
Tried it, but get the error invalid use of null. The field I tried it on had no NULL values. Will figure it out. RBS > RB Smissaert wrote: >> When moving data from Interbase to SQLite I have to convert integer >> dates in >> the format mmdd to Excel dates. These are integer numbers counting

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Nicolas Williams
On Sun, Dec 03, 2006 at 05:31:55PM +, RB Smissaert wrote: > Still have the problem though how to compare dates in SQLite when the format > is the integer mmdd. Maybe I will need some custom SQLite function. What's difficult about comparing integers of the form mmdd? Comparing them is

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Dennis Cote
[EMAIL PROTECTED] wrote: Thanks, will try that. What does the: % 100 do and what the Excel_date ? The % is the modulus operator. It returns the remainder after division by a number. For example, 1234 divided by 100 gives 12 and a remainder of 34. The '/' division operator returns the

Re: [sqlite] Batching functions

2006-12-04 Thread Nicolas Williams
On Sun, Dec 03, 2006 at 11:24:36PM -0600, John Stanton wrote: > How about running a daemon on your machine which gets the request from > your user defined function, does the lookup with a persistent connection > and asynchronously updates the row in the DB? It does not need to be a > daemon,

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Dennis Cote
[EMAIL PROTECTED] wrote: Thanks , will try that. What is as excel_date? Is this a variable or is this jus plain SQL against SQLite? Bart, excel_date is just a normal SQL alias name for the complicated expression. The string 'execl_date' will be returned as the name of this result column.

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
Thanks, will try that. What does the: % 100 do and what the Excel_date ? RBS > RB Smissaert wrote: >> When moving data from Interbase to SQLite I have to convert integer >> dates in >> the format mmdd to Excel dates. These are integer numbers counting >> the >> days past 31 December 1899.

RE: [sqlite] Time formatting

2006-12-04 Thread Karthick V - TLS , Chennai
Hi Dennis, Thanks for the code, made me think of an alternate approach. Tried out your code and made some changes. Here is the updated version select strftime('%Y-%m-%dT%H:%M:%f', localtime) || case when (strftime('%s',localtime) - strftime('%s',GMTTime)) > 0 then '+' ||

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
Thanks , will try that. What is as excel_date? Is this a variable or is this jus plain SQL against SQLite? RBS > RB Smissaert wrote: >> When moving data from Interbase to SQLite I have to convert integer >> dates in >> the format mmdd to Excel dates. These are integer numbers counting >> the

RE: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Denis Povshedny
Hi RBS! In my application I use following approach: It is a part of view to export csv data to Excel: CREATE VIEW v_export_data_std AS SELECT localnumber, remotenumber, sipuser, strftime( "%Y", timestart, 'unixepoch', 'localtime' ) AS year, strftime(

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Dennis Cote
RB Smissaert wrote: When moving data from Interbase to SQLite I have to convert integer dates in the format mmdd to Excel dates. These are integer numbers counting the days past 31 December 1899. With substr I can make it dd/mm/ (I am in the UK and that is the normal way to format dates)

Re: [sqlite] is blob compression worth it

2006-12-04 Thread Günter Greschenz
hi, i've written a field-based compression using bzip2. my experience: the fields must have at least 50 bytes, or the compressed data is bigger ! cu, gg Hickey, Larry schrieb: I have a blob structure which is primarily doubles. Is there anyone with some experience with doing data compression

Re: [sqlite] sqlite3_open (new Win32 thread)

2006-12-04 Thread Dennis Cote
Dixon Hutchinson wrote: I think this is a different question, unrelated to the previous sqlite_open thread. I'm in a WIN32 environment. I'm using: h = CreateFile(path, GENERIC_READ, FILE_SHARE_READ || FILE_SHARED_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); to

[sqlite] is blob compression worth it

2006-12-04 Thread Hickey, Larry
I have a blob structure which is primarily doubles. Is there anyone with some experience with doing data compression to make the blobs smaller? Tests I have run so far indicate that compression is too slow on blobs of a few meg to be practical. I get now at least 20 to 40 inserts per second

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread bartsmissaert
Well, these fields I am talking about hold date information but they have nil to do with dates in that you can't do any date manipulation on the data. There also are proper date-time fields in the database and they hold something entirely different. The first field (with mmdd) hold a long data

AW: [sqlite] for what reason :memory: is much slower than /dev/s hm/dummy.db

2006-12-04 Thread roland . gremmelspacher
> -Ursprüngliche Nachricht- > Von: John Stanton [mailto:[EMAIL PROTECTED] > Gesendet: Freitag, 1. Dezember 2006 19:59 > An: sqlite-users@sqlite.org > Betreff: Re: [sqlite] for what reason :memory: is much slower than > /dev/shm/dummy.db > > > Eduardo Morras wrote: > > At 09:34