Re: [sqlite] Simple read-only program very slow

2017-12-04 Thread Keith Medcalf

>All of my machines are 64-bit, and run 64-bit Linux kernels.  Python3
>is a 64-bit executable according to 'file'.

>I re-ran the whole thing (slightly modified to also do a test on
>pmain) on my big dual-Xeon (32 hyperthreads, 256GB! RAM ) from 
>System76.  In spite of having about half the CPU clock speed, 
>and being single-thread, it ran about 5 times faster.  

>I take this to mean that it really helps if the entire database 
>fits in the kernel memory buffers.  Kinda like putting it
>on an SSD, only better.  

There are multiple levels of caching.  There is the block I/O cache, the device 
cache, the OS filesystem cache and also the SQLite3 page cache.  Even if *all* 
the database fits in the OS filesystem cache, you will still have quite a bit 
of a slowdown if the SQLite3 page cache is not big enough to hold the "working 
set" of pages necessary to traverse the B-Tree structures (indexes and tables). 
 By default the SQLite3 page cache is a paltry 2 pages (which at a 4K page 
size is probably big enough for a small database (a gig or two) to have decent 
performance).  This cache can "thrash" as well.

Thashing against the OS Filesystem cache is significantly faster than thrashing 
down to actual physical I/O, but is still significantly slower than if it does 
not thrash or thrashes within the I/O rate of the underlying physical 
storage/cache system.

If you read the hitrate and it is small (I define small as less than 99% -- you 
may want more thrashing) then your page cache (PRAGMA page_cache) is too small:

def hitrate(db):
hits = db.status(apsw.SQLITE_DBSTATUS_CACHE_HIT)[0]
misses = db.status(apsw.SQLITE_DBSTATUS_CACHE_MISS)[0]
return hits * 100.0 / max(hits + misses, 1)

There is also of course a point at which it is more efficient to do an I/O (I/O 
time) than it is to search the page cache (CPU time).  Don't know where that is 
but of course there is such a point.  Truly you want to find the point at which 
SQLite3's page cache is sufficient to maintain the I/O rate to the next lower 
level as low as possible, and no lower.  Hard to guess what that number is and 
it costs big bucks to performance tune computers to balance workloads to keep 
every component of the system just ever so slightly under 100% utilized 100% of 
the time (that is, operating at peak speed).

>I also take it to mean two other things:

>1. I should have been more careful to make sure the system was 
>in the same state on every trial.  It makes a difference if 
>part of the DB is already in the buffers.

>2. Most of the slowdown was buffer thrashing, caused by an 
>access pattern that had to read some parts of the database 
>several times.

>I no longer think this is any kind of a problem in SQLite.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Simple read-only program very slow

2017-12-04 Thread Kevin O'Gorman
On Sun, Dec 3, 2017 at 8:49 AM, Keith Medcalf  wrote:

>
> On Sunday, 3 December, 2017 08:24, Richard Rousselot <
> richard.rousse...@gmail.com> wrote:
>
> >Had similar issue a few years ago; we were using the SQLite3.exe.  We
> >recompiled the exe as 64 bit which allowed it to use more than 4 GB
> >of ram, loaded the machine with as much memory as we could.  Voila,
> >super fast processing.
>
> >Can the Python libraries be made 64 bit some how?
>
> Yes.  You must be using a 64-bit version of Python and the procedure to
> replace the sqlite3.dll / sqlite3.so it uses is the same as for the 32-bit
> version, or to compile and use a 64-bit version of the apsw extension is
> unchanged.
>
> Neither Windows nor Linux can thunk a dynamic load module such that the
> one used is a different model than the running process (it was proprietary
> IBM technology that no one else seems smart enough to duplicate), so you
> have to update Python to the 64-bit model as well.
>
> On Windows 10 16299.98 I have both a 32-bit (Python 2.7.14) and 64-bit
> (Python 3.6.4) installed and build 32-bit DLLs for the former and 64-bit
> for the latter from the same source (just selecting -m32 or -m64 as
> appropriate).  I use the MinGW64/GCC compiler because (a) it can compile in
> either model depending on the switch you use without requiring any code
> changes, (b) supports long long and long double in 32-bit; and, (c) does
> not require the use of the Microsoft C Runtime "moving target" libraries --
> it can compile to the subsystem runtime (MSVCRT) that has been stable
> since, oh, the first OS/2 New Technology (which later became Windows NT)
> way back when.  Oh, and MinGW/GCC does "true" position independent code and
> when you do a static link of a module to either and executable or dynamic
> load library, it is truly static with no strange external dependencies.
>
> Since SQLite3 is heavily I/O bound (or at least syscall/kernel call bound
> for mutexes, etc) in practically everything it does, the 64-bit version is
> much faster (about 20%) than the 32-bit version, when running on a 64-bit
> OS, since the OS does not have to thunk the call stack when
> accessing/returning from  the kernel.
>
> >On Thu, Nov 30, 2017 at 7:01 PM Keith Medcalf 
> >wrote:
> >
> >>
> >> Is there an index on pos where ppos is the left-most field (or the
> >only
> >> field) in the index?
> >> What is the column affinity of ppos?  Of the fiold you are passing
> >as a
> >> parameter?
> >> Is ppos unique?
> >>
> >> If you CREATE [UNIQUE] INDEX searchindex ON pos (ppos, pnum);
> >>
> >> then your query can be satisfied only using the searchindex
> >covering index.
> >>
> >> If there is not an index on ppos, then you will be wasting time
> >recreating
> >> the index for each query.
> >>
> >> You will probably need to increase the cache size beyond the paltry
> >> default in order for the entire btree structures to be cached in
> >RAM -- you
> >> probably want to make it as big as you can.
> >>
> >> ---
> >> The fact that there's a Highway to Hell but only a Stairway to
> >Heaven says
> >> a lot about anticipated traffic volume.
> >>
> >>
> >> >-Original Message-
> >> >From: sqlite-users [mailto:sqlite-users-
> >> >boun...@mailinglists.sqlite.org] On Behalf Of Kevin O'Gorman
> >> >Sent: Saturday, 25 November, 2017 20:14
> >> >To: sqlite-users
> >> >Subject: [sqlite] Simple read-only program very slow
> >> >
> >> >I'm pretty new at SQLite, so this may seem obvious to you.  Be
> >kind.
> >> >I'm using Python on Ubuntu Linux 16.04 LTS, and the sqlite that is
> >> >built
> >> >into Python.  The database
> >> >is using WAL.
> >> >
> >> >I've got a database of some 100 million records, and a file of
> >just
> >> >over
> >> >300 thousand that I want represented in it.  I wanted to check how
> >> >much
> >> >difference it was going to make, so I wrote a super
> >> >simple program to the read the file and count how many records are
> >> >already
> >> >there.  I got impatient waiting for it so I killed the process and
> >> >added an
> >> >output of one dot (".") per 1000 records.  It went very fast for
> >what
> >> >I
> >> >estimate was around 200 dots and hit a wall.  It made progress,
> >but
> >> >very
> >> >very slowly.
> >> >
> >> >So I killed it again and added a commit() call every time it
> >output a
> >> >dot.
> >> >It didn't hit a wall, just some rough road (that is, it slowed
> >down
> >> >at
> >> >about the same spot but not nearly so drastically).
> >> >
> >> >The code makes to changes to the database at all.  Why does
> >commit()
> >> >make a
> >> >difference?  What else should I learn from this?
> >> >
> >> >The field being used for the lookup has an index.
> >> >
> >> >++ kevin
> >> >
> >> >Code follows:
> >> >#!/usr/bin/env python3
> >> >"""Count the number of records that represent rows in the database
> >> >'pos'
> >> >table.
> >> >The database is not modified.
> >> >
> >> > Last Modified: Sat Nov 25 

Re: [sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Keith Medcalf
On Monday, 4 December, 2017 15:44, Jens Alfke  wrote:

>> If one object is using, for example, the multithreaded runtime and
>>the others are using the single threaded runtime (for example), and
>>the third perhaps the subsystem runtime

>From the OP’s other thread here it looks like they’re developing for
>iOS or macOS, neither of which have the sorts of multiple runtimes
>you’re talking about (is that a Windows thing?)

I had believed it was Windows since "DLL" was mentioned and that is a Windows 
(or OS/2) contraction for dynamic load library.  I don't think anything else 
uses that term in quite the same way.

The multiple library is a Microsoft thing designed to ensure a continuous 
revenue stream by ensuring that each version of their development platform is 
incompatible with all prior versions.  Once you start using Microsoft tools for 
anything you are stuck (locked in) into a perpetual cycle of re-writing and 
re-development of every single thing due to their planned obsolescence 
requiring re-purchasing tools and redeveloping everything practically 
fortnightly.  The "newer fangled" the technology (from a Microsoft hype 
perspective) the shorter its viability.  This is in contrast to where, for 
example, one avoids Microsoft tools like the plague, and you end up with stuff 
that works perfectly for decades on multiple versions of Windows.  This does 
not generate continuous upgrade revenue for either Microsoft or the developer 
(if it ain't broke why fix it) so typically there is a preponderance of 
deliberate lock-in by all parties in the Microsoft world.

>Also, I don’t see how static libraries can end up using different
>runtime libraries, since the runtime gets linked in by the linker,
>after the static libs are compiled. But maybe that’s another Windows
>thing.

Because for the greater certainty of lock-in, the runtime entry point names are 
different depending on the version of the Toolchain and the particular link 
library you compiled the object for.  In many cases you cannot simply remove 
the linkage records from the objects and link with a substitute library (though 
sometimes you can).  You have to rebuild the whole thing again. You can link 
against the platform subsystem library, but that is recommended against because 
it makes the resultant executable too portable across versions of Windows.





___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Jens Alfke


> On Dec 4, 2017, at 2:25 PM, Keith Medcalf  wrote:
> 
> If one object is using, for example, the multithreaded runtime and the others 
> are using the single threaded runtime (for example), and the third perhaps 
> the subsystem runtime

From the OP’s other thread here it looks like they’re developing for iOS or 
macOS, neither of which have the sorts of multiple runtimes you’re talking 
about (is that a Windows thing?)

Also, I don’t see how static libraries can end up using different runtime 
libraries, since the runtime gets linked in by the linker, after the static 
libs are compiled. But maybe that’s another Windows thing.

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Keith Medcalf
On Monday, 4 December, 2017 15:03, Jens Alfke  wrote:
>> On Dec 4, 2017, at 11:59 AM, Keith Medcalf 
>>wrote:

>> You should only be defining SQLITE_CORE if in fact the extension is
>>part of the core -- that is compiled and included (statically linked)
>>to the core sqlite3.c compilation unit.

>Which it is, in this case. The OP said that both sqlite and the
>extension are static libraries, so they’re both being linked directly
>into the executable.

Hmmm.  You are right.  I read is as statically linked loadlibs (DLLs) not as 
all the object modules were linked together into a single executable; then you 
are right, there should not be an issue.  However, each compilation unit still 
must be using the same single uniform runtime library.  If one object is using, 
for example, the multithreaded runtime and the others are using the single 
threaded runtime (for example), and the third perhaps the subsystem runtime, 
you will end up with the same runtime collisions after they are linked together.

>I’m not sure what’s going on. Life, can you post a backtrace of the
>crash?

And perhaps use the dependency walker (depends.exe) on the executable and see 
if multiple runtimes are being loaded ...




___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling on Xcode

2017-12-04 Thread Jens Alfke


> On Nov 24, 2017, at 10:14 AM, Lifepillar  wrote:
> 
> When building sqlite-amalgamation-321 using Xcode 9.1 in a newly
> created project, I get a few dozen warnings

Yup, and this is an FAQ. SQLite is very thoroughly tested but the developers do 
not use compiler warnings.

> To avoid missing potential problems in the rest of your code, I'd
> recommend suppressing the warnings only for the Release
> configuration and only for the specific target.

I recommend building SQLite as a separate static-library target, and linking 
the library into your app target. That way you can turn off warnings for SQLite 
without affecting your own code.

—Jens

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-12-04 14:33 GMT+01:00 Cecil Westerhof :

>
>
> 2017-11-19 23:00 GMT+01:00 jungle boogie :
>
>> Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
>>
>>> I found the benefits for TCL/TK. But this is a SQLite mailing list, so
>>> not
>>> the right place to ask questions if it is not connected to SQLite also.
>>> What would be good resources for TCL/TK?
>>>
>>>
>> There's also a pretty active IRC room on freenode, it's #tcl.
>>
>> Let us know how your experiences go with tcl.
>
>
​I also made a script to store the values from vmstat:

#!/usr/bin/env tclsh

### Improvements
# Get database from conf-file


package require sqlite3


if {$argc != 1} {
error "Error: ${argv0} DATABASE"
}
sqlite db [lindex $argv 0]
db timeout 1
setinsertVmstat "
INSERT INTO vmstat (
runlength,
-- procs
runable, uninteruptable,
-- memory
swap,free,  buffers,  cache,
-- swap
swapIn,  swapOut,
-- io
blockIn, blockOut,
-- system
interuptsPerSec, contextSwitchesPerSec,
-- cpu
userTime,systemTime,idleTime, waitTime,
stolenTime
) VALUES (
:runLength,
:runable, :uninteruptable,
:swap, :free, :buffers, :cache,
:swapIn, :swapOut,
:blockIn, :blockOut,
:interuptsPerSec, :contextSwitchesPerSec,
:userTime, :systemTime, :idleTime, :waitTime, :stolenTime
);
"
set   runLength 60
puts  "Using an interval of ${runLength} seconds"
after [expr {1000 * (60 - [clock seconds] % 60)}]
set   vmstat [open "|vmstat -n ${runLength}"]
# The first three lines need to be skipped
for {set i 0} {${i} < 3} {incr i} {
gets ${vmstat}
}
while {true} {
lassign [gets ${vmstat}] \
runable uninteruptable   \
swapfree  buffers  cache \
swapIn  swapOut  \
blockIn blockOut \
interuptsPerSec contextSwitchesPerSec\
userTimesystemTimeidleTime waitTime stolenTime
db eval ${insertVmstat}
}
# Not really necessary because the above loop never ends
# But I find this more clear and is robuster against change
close vmstat
dbclose

-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Article on AUTOINC vs. UUIDs

2017-12-04 Thread Jens Alfke


> On Nov 30, 2017, at 6:52 AM, Stephen Chrzanowski  wrote:
> 
> I'm going to read it later, but, I'll be going in skeptical.  Collision is
> real, even at 128-bit resolution

IIRC, to have a realistic chance of a collision you'd have to generate about 
√(2^128) UUIDs, which is 2^64, which about 2 x 10^19, i.e. 20 quintillion. I 
don’t think there’s a real chance that this database will be in operation long 
enough to generate that many records!

UUIDs are probably overkill for typical databases, but they’re extremely useful 
for distributed ones, where a centralized counter becomes both a performance 
bottleneck, a single point of failure, and in some cases (P2P) a trust problem.

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Jens Alfke


> On Dec 4, 2017, at 11:59 AM, Keith Medcalf  wrote:
> 
> You should only be defining SQLITE_CORE if in fact the extension is part of 
> the core -- that is compiled and included (statically linked) to the core 
> sqlite3.c compilation unit. 

Which it is, in this case. The OP said that both sqlite and the extension are 
static libraries, so they’re both being linked directly into the executable.

I’m not sure what’s going on. Life, can you post a backtrace of the crash?

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Lifepillar

On 04/12/2017 20:59, Keith Medcalf wrote:


You should only be defining SQLITE_CORE if in fact the extension is part of the 
core -- that is compiled and included (statically linked) to the core sqlite3.c 
compilation unit.  In this case, the extension makes direct calls to the 
sqlite3 entry points and shares the same runtime as the sqlite3 core engine.

If the extension is *not* part of the same linkage unit as sqlite3.c, then it 
cannot access the sqlite3 core functions using direct linkage and must instead 
use a structure of function pointers (aka a class) for indirect access.

Having an extension be a part of the core but not telling it so is only 
deleterious to performance (linkage is via indirect function pointers rather 
than static linkage).

Telling an extension that it is part of the core when it is not will lead to 
memory access errors, either due to bad loadtime linkage or more likely to the 
fact that it is using a separate runtime heap and/or stack manager and neither 
the extension nor the actual sqlite3 core can manage each others' memory 
allocations.

Got it. I had misinterpreted the documentation in a way that—
now I realize—doesn't make much sense.

Thanks for the clear explanation!
Life.

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Keith Medcalf

You should only be defining SQLITE_CORE if in fact the extension is part of the 
core -- that is compiled and included (statically linked) to the core sqlite3.c 
compilation unit.  In this case, the extension makes direct calls to the 
sqlite3 entry points and shares the same runtime as the sqlite3 core engine.

If the extension is *not* part of the same linkage unit as sqlite3.c, then it 
cannot access the sqlite3 core functions using direct linkage and must instead 
use a structure of function pointers (aka a class) for indirect access.

Having an extension be a part of the core but not telling it so is only 
deleterious to performance (linkage is via indirect function pointers rather 
than static linkage).

Telling an extension that it is part of the core when it is not will lead to 
memory access errors, either due to bad loadtime linkage or more likely to the 
fact that it is using a separate runtime heap and/or stack manager and neither 
the extension nor the actual sqlite3 core can manage each others' memory 
allocations.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Lifepillar
>Sent: Monday, 4 December, 2017 12:45
>To: sqlite-users@mailinglists.sqlite.org
>Subject: [sqlite] Cannot initialize statically linked extension
>
>Hello,
>I need some help to figure out a segfault. I have:
>
>- SQLite3 3.21.0 compiled as a static library;
>- a custom extension compiled as another static library,
>   passing -DSQLITE_CORE.
>- a simple main program linked to both libraries.
>
>My extension has the typical structure, nothing fancy.
>
>My main() function contains the following snippet:
>
>  int rc = sqlite3_open(":memory:", );
>   if (rc != SQLITE_OK) {
> sqlite3_close(db);
> return rc;
>   }
>   char* zErrMsg;
>   //sqlite3_myextension_init(db, , 0);
>
>This works fine: I can use SQLite functions without problems.
>But, if I un-comment the line that invokes the entry point of
>my extension (the last line of the snippet above), the program
>crashes with a bad memory access error.
>
>Btw, if I build my extension as a dynamic library and load it
>in a SQLite shell, all is fine.
>
>Any idea what may be wrong?
>
>Thanks,
>Life.
>
>
>
>
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Cannot initialize statically linked extension

2017-12-04 Thread Lifepillar

Hello,
I need some help to figure out a segfault. I have:

- SQLite3 3.21.0 compiled as a static library;
- a custom extension compiled as another static library,
  passing -DSQLITE_CORE.
- a simple main program linked to both libraries.

My extension has the typical structure, nothing fancy.

My main() function contains the following snippet:

 int rc = sqlite3_open(":memory:", );
  if (rc != SQLITE_OK) {
sqlite3_close(db);
return rc;
  }
  char* zErrMsg;
  //sqlite3_myextension_init(db, , 0);

This works fine: I can use SQLite functions without problems.
But, if I un-comment the line that invokes the entry point of
my extension (the last line of the snippet above), the program
crashes with a bad memory access error.

Btw, if I build my extension as a dynamic library and load it
in a SQLite shell, all is fine.

Any idea what may be wrong?

Thanks,
Life.




___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Why Unicode is difficult

2017-12-04 Thread Keith Medcalf

That depends if the value of the table column called "1" is 1 or not ...

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Stephen Chrzanowski
>Sent: Monday, 4 December, 2017 12:01
>To: SQLite mailing list
>Subject: Re: [sqlite] Why Unicode is difficult
>
>... as in how 1 != "1"?
>
>On Mon, Dec 4, 2017 at 11:07 AM, Igor Korot 
>wrote:
>
>> Hi,
>>
>> On Mon, Dec 4, 2017 at 7:42 AM, Jay Kreibich  wrote:
>> >
>> >
>> > Next, we can talk about how dates and times are simple and
>> straight-forward.
>>
>> And then the number representation...
>>
>> Thank you.
>>
>> >
>> >  -j
>> >
>> >
>> >
>> >> On Dec 4, 2017, at 7:08 AM, Simon Slavin 
>wrote:
>> >>
>> >> Every so often someone asks on this list for Unicode to be
>handled
>> properly.  I did it myself.  Then other people have to explain how
>hard
>> this is.  So here’s an article which, after introductory material,
>> discusses the hard questions in Unicode:
>> >>
>> >> Unicode.html>
>> >>
>> >> Are two strings the same?
>> >> How long is a string?
>> >> How do you sort things in alphabetical order?
>> >>
>> >> The first and third questions are requirements for implementing
>COLLATE
>> in SQLite.  And the fact that the second question is a difficult
>one
>> emphasises that one shouldn’t take Unicode as simple.
>> >>
>> >> Simon.
>> >> ___
>> >> sqlite-users mailing list
>> >> sqlite-users@mailinglists.sqlite.org
>> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>> >
>> > ___
>> > sqlite-users mailing list
>> > sqlite-users@mailinglists.sqlite.org
>> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>> ___
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Why Unicode is difficult

2017-12-04 Thread Jay Kreibich

> On Dec 4, 2017, at 1:33 PM, Igor Korot  wrote:
> 
> Stephen,
> 
> On Mon, Dec 4, 2017 at 1:01 PM, Stephen Chrzanowski  
> wrote:
>> ... as in how 1 != "1"?
> 
> No.
> 1000 vs 1,000 vs 1.000 vs 1,000.00 vs whatever.

I thought you meant how to represent 0.1

And the fact there are so many interpretations of “number representation” aught 
to give a clue about how complex something “so simple” can be.

 -j



> 
>> 
>> On Mon, Dec 4, 2017 at 11:07 AM, Igor Korot  wrote:
>> 
>>> Hi,
>>> 
>>> On Mon, Dec 4, 2017 at 7:42 AM, Jay Kreibich  wrote:
 
 Next, we can talk about how dates and times are simple and 
 straight-forward.
>>> 
>>> And then the number representation...
>>> 

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Why Unicode is difficult

2017-12-04 Thread Igor Korot
Stephen,

On Mon, Dec 4, 2017 at 1:01 PM, Stephen Chrzanowski  wrote:
> ... as in how 1 != "1"?

No.
1000 vs 1,000 vs 1.000 vs 1,000.00 vs whatever.

>
> On Mon, Dec 4, 2017 at 11:07 AM, Igor Korot  wrote:
>
>> Hi,
>>
>> On Mon, Dec 4, 2017 at 7:42 AM, Jay Kreibich  wrote:
>> >
>> >
>> > Next, we can talk about how dates and times are simple and
>> straight-forward.
>>
>> And then the number representation...
>>
>> Thank you.
>>
>> >
>> >  -j
>> >
>> >
>> >
>> >> On Dec 4, 2017, at 7:08 AM, Simon Slavin  wrote:
>> >>
>> >> Every so often someone asks on this list for Unicode to be handled
>> properly.  I did it myself.  Then other people have to explain how hard
>> this is.  So here’s an article which, after introductory material,
>> discusses the hard questions in Unicode:
>> >>
>> >> 
>> >>
>> >> Are two strings the same?
>> >> How long is a string?
>> >> How do you sort things in alphabetical order?
>> >>
>> >> The first and third questions are requirements for implementing COLLATE
>> in SQLite.  And the fact that the second question is a difficult one
>> emphasises that one shouldn’t take Unicode as simple.
>> >>
>> >> Simon.
>> >> ___
>> >> sqlite-users mailing list
>> >> sqlite-users@mailinglists.sqlite.org
>> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>> >
>> > ___
>> > sqlite-users mailing list
>> > sqlite-users@mailinglists.sqlite.org
>> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>> ___
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Keith Medcalf

CPython can calculate the factorial of 108000 in less than 4 seconds :)

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.

>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of J Decker
>Sent: Monday, 4 December, 2017 09:06
>To: SQLite mailing list
>Subject: Re: [sqlite] Good resources for TCL/TK
>
>On Sat, Nov 18, 2017 at 6:35 AM, Cecil Westerhof
>
>wrote:
>
>> 2017-11-18 15:14 GMT+01:00 Eric :
>>
>> > On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
>> > cldwester...@gmail.com> wrote:
>> > > I found the benefits for TCL/TK. But this is a SQLite mailing
>list, so
>> > not
>> > > the right place to ask questions if it is not connected to
>SQLite also.
>> > > What would be good resources for TCL/TK?
>> > >
>> >
>> > There is the Usenet group comp.lang.tcl , also accessible through
>Google
>> > Groups at https://groups.google.com/forum/#!forum/comp.lang.tcl .
>> >
>> > There is also the Tclers' Wiki at http://wiki.tcl.tk/ which is
>full
>> > of information. You can ask questions by editing them into the
>"Ask,
>> > and it shall be given" page http://wiki.tcl.tk/37862 .
>> >
>>
>> ​Thanks, I will look into those.
>>
>>
>> By the way TCL can calculate factorial 995 in less as 4 seconds.
>Not to
>> bad.
>>
>
>https://gist.github.com/d3x0r/924b618d4cdb81c0cc813987090395b5
>node can calculate factorial 32000 in less than 4 seconds :)
>
>>
>> --
>> Cecil Westerhof
>> ___
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Why Unicode is difficult

2017-12-04 Thread Stephen Chrzanowski
... as in how 1 != "1"?

On Mon, Dec 4, 2017 at 11:07 AM, Igor Korot  wrote:

> Hi,
>
> On Mon, Dec 4, 2017 at 7:42 AM, Jay Kreibich  wrote:
> >
> >
> > Next, we can talk about how dates and times are simple and
> straight-forward.
>
> And then the number representation...
>
> Thank you.
>
> >
> >  -j
> >
> >
> >
> >> On Dec 4, 2017, at 7:08 AM, Simon Slavin  wrote:
> >>
> >> Every so often someone asks on this list for Unicode to be handled
> properly.  I did it myself.  Then other people have to explain how hard
> this is.  So here’s an article which, after introductory material,
> discusses the hard questions in Unicode:
> >>
> >> 
> >>
> >> Are two strings the same?
> >> How long is a string?
> >> How do you sort things in alphabetical order?
> >>
> >> The first and third questions are requirements for implementing COLLATE
> in SQLite.  And the fact that the second question is a difficult one
> emphasises that one shouldn’t take Unicode as simple.
> >>
> >> Simon.
> >> ___
> >> sqlite-users mailing list
> >> sqlite-users@mailinglists.sqlite.org
> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
> > ___
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Error code 14 for the Journal file

2017-12-04 Thread Chris Locke
The 'scary bit' here is the device not functioning.
> A device attached to the system is not functioning.

Is the database/journal on the same/local PC or on a network?


Chris

On Mon, Dec 4, 2017 at 4:27 PM, Simon Slavin  wrote:

>
>
> On 4 Dec 2017, at 9:31am, Tilak Vijayeta  wrote:
>
> > PID:02FB0036 TID:06B60006 SQLite error (14): os_win.c:36317: (31)
> winOpen(\--\TTDB.db3-journal) - A device attached to the system is
> not functioning.
>
> You appear to have a hardware or operating system problem which is causing
> a SQLite error.  SQLite error 14 is "Unable to open the database file".
>
> Is there some sort of protection on the journal file, or on the directory
> it’s in, which is preventing your program from accessing it ?
>
> > PID:02FB0036 TID:06B60006 SQLite error (778): os_win.c:34215: (5)
> winWrite2(\\TTDB.db3-journal) - Access is denied.
>
> "Access is denied" suggests there is some sort of protection or access
> problem.
>
> > 1.A Journal file gets created as a backup on every transaction,
> as in Update or Insert. This file gets deleted after the transaction is
> committed.
>
> This is not normal for SQLite.  Can you tell us the result of
>
> PRAGMA journal_mode
>
> for whatever database file you’re accessing ?
>
> > 2.   I assumed that the journal file goes 'Read Only' sometimes
> because of which Delete operation fails.
>
> That is not something SQLite does.
>
> > 3.   To fix it, every time I come across a SQL Lite error 14, I
> change the read only property of the Journal file.
>
> This does not fit the way SQLite works.  If you are in a situation where
> you have to do this, you have more serious problems which you will have to
> deal with later.  You have something which is preventing SQLite from
> working properly.  Are you running any anti-virus program ?  Can you
> disable it temporarily while you test your program to see if it’s the
> culprit ?
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Gerry Snyder
Sorry, I did not notice that your question was about exec rather than expr.

Gerry

On Dec 4, 2017 8:40 AM, "Gerry Snyder"  wrote:

> No. One set of braces around the whole list of arguments.
>
> Gerry
>
> On Dec 4, 2017 8:27 AM, "Cecil Westerhof"  wrote:
>
>> 2017-12-04 15:24 GMT+01:00 Gerry Snyder :
>>
>> > It is always a good idea to put the arguments of [expr] in braces. That
>> way
>> > they are byte-compiled.
>> >
>>
>> ​You mean like:
>> exec {swapon} (--noheadings} {--show}
>>
>> --
>> Cecil Westerhof
>> ___
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Error code 14 for the Journal file

2017-12-04 Thread Simon Slavin


On 4 Dec 2017, at 9:31am, Tilak Vijayeta  wrote:

> PID:02FB0036 TID:06B60006 SQLite error (14): os_win.c:36317: (31) 
> winOpen(\--\TTDB.db3-journal) - A device attached to the system is not 
> functioning.

You appear to have a hardware or operating system problem which is causing a 
SQLite error.  SQLite error 14 is "Unable to open the database file".

Is there some sort of protection on the journal file, or on the directory it’s 
in, which is preventing your program from accessing it ?

> PID:02FB0036 TID:06B60006 SQLite error (778): os_win.c:34215: (5) 
> winWrite2(\\TTDB.db3-journal) - Access is denied.

"Access is denied" suggests there is some sort of protection or access problem.

> 1.A Journal file gets created as a backup on every transaction, as in 
> Update or Insert. This file gets deleted after the transaction is committed.

This is not normal for SQLite.  Can you tell us the result of

PRAGMA journal_mode

for whatever database file you’re accessing ?

> 2.   I assumed that the journal file goes 'Read Only' sometimes because 
> of which Delete operation fails.

That is not something SQLite does.

> 3.   To fix it, every time I come across a SQL Lite error 14, I change 
> the read only property of the Journal file.

This does not fit the way SQLite works.  If you are in a situation where you 
have to do this, you have more serious problems which you will have to deal 
with later.  You have something which is preventing SQLite from working 
properly.  Are you running any anti-virus program ?  Can you disable it 
temporarily while you test your program to see if it’s the culprit ?

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Why Unicode is difficult

2017-12-04 Thread Igor Korot
Hi,

On Mon, Dec 4, 2017 at 7:42 AM, Jay Kreibich  wrote:
>
>
> Next, we can talk about how dates and times are simple and straight-forward.

And then the number representation...

Thank you.

>
>  -j
>
>
>
>> On Dec 4, 2017, at 7:08 AM, Simon Slavin  wrote:
>>
>> Every so often someone asks on this list for Unicode to be handled properly. 
>>  I did it myself.  Then other people have to explain how hard this is.  So 
>> here’s an article which, after introductory material, discusses the hard 
>> questions in Unicode:
>>
>> 
>>
>> Are two strings the same?
>> How long is a string?
>> How do you sort things in alphabetical order?
>>
>> The first and third questions are requirements for implementing COLLATE in 
>> SQLite.  And the fact that the second question is a difficult one emphasises 
>> that one shouldn’t take Unicode as simple.
>>
>> Simon.
>> ___
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread J Decker
On Sat, Nov 18, 2017 at 6:35 AM, Cecil Westerhof 
wrote:

> 2017-11-18 15:14 GMT+01:00 Eric :
>
> > On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
> > cldwester...@gmail.com> wrote:
> > > I found the benefits for TCL/TK. But this is a SQLite mailing list, so
> > not
> > > the right place to ask questions if it is not connected to SQLite also.
> > > What would be good resources for TCL/TK?
> > >
> >
> > There is the Usenet group comp.lang.tcl , also accessible through Google
> > Groups at https://groups.google.com/forum/#!forum/comp.lang.tcl .
> >
> > There is also the Tclers' Wiki at http://wiki.tcl.tk/ which is full
> > of information. You can ask questions by editing them into the "Ask,
> > and it shall be given" page http://wiki.tcl.tk/37862 .
> >
>
> ​Thanks, I will look into those.
>
>
> By the way TCL can calculate factorial 995 in less as 4 seconds. Not to
> bad.
>

https://gist.github.com/d3x0r/924b618d4cdb81c0cc813987090395b5
node can calculate factorial 32000 in less than 4 seconds :)

>
> --
> Cecil Westerhof
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-12-04 16:40 GMT+01:00 Gerry Snyder :

> No. One set of braces around the whole list of arguments.
>

​That does not work:
exec {swapon --noheadings --show}
couldn't execute "swapon --noheadings --show": no such file or directory
while evaluating {exec {swapon --noheadings --show}}

or:
exec swapon {--noheadings --show}
swapon: unrecognized option '--noheadings --show'
​


On Dec 4, 2017 8:27 AM, "Cecil Westerhof"  wrote:
>
> > 2017-12-04 15:24 GMT+01:00 Gerry Snyder :
> >
> > > It is always a good idea to put the arguments of [expr] in braces. That
> > way
> > > they are byte-compiled.
> > >
> >
> > ​You mean like:
> > exec {swapon} (--noheadings} {--show}
>

-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Gerry Snyder
No. One set of braces around the whole list of arguments.

Gerry

On Dec 4, 2017 8:27 AM, "Cecil Westerhof"  wrote:

> 2017-12-04 15:24 GMT+01:00 Gerry Snyder :
>
> > It is always a good idea to put the arguments of [expr] in braces. That
> way
> > they are byte-compiled.
> >
>
> ​You mean like:
> exec {swapon} (--noheadings} {--show}
>
> --
> Cecil Westerhof
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Malcolm Greene
Python has some good bindings for TLC/TK and SQLite. These bindings are
built into the Python standard library and work cross-platform with no
additional dependencies other than the core Python install.

Malcolm
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Peter Da Silva
Like
  expr {sqrt($foo) < 3.7 && $bazflag > 0}

Instead of
  expr sqrt($foo) < 3.7 && $bazflag > 0

Same for the first argument to “if”, second argument to “for”, etc.

On 12/4/17, 9:27 AM, "sqlite-users on behalf of Cecil Westerhof" 
 wrote:

2017-12-04 15:24 GMT+01:00 Gerry Snyder :

> It is always a good idea to put the arguments of [expr] in braces. That 
way
> they are byte-compiled.
>

​You mean like:
exec {swapon} (--noheadings} {--show}



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Error code 14 for the Journal file

2017-12-04 Thread Tilak Vijayeta
Greetings,
In my application, we are  supposed to save a timestamp every 10 seconds. To 
achieve this, we read data from a table say GlobalStatistics and the update the 
same GlobalStatistics with a new set of data.
This operation happens after every 10 seconds apart from the other tasks that 
the application performs.
I encounter this error, especially when the application remains idle(not 
necessarily the cause or the reason)

PID:02FB0036 TID:06B60006 SQLite error (14): os_win.c:36317: (31) 
winOpen(\--\TTDB.db3-journal) - A device attached to the system is not 
functioning.
PID:02FB0036 TID:06B60006 SQLite error (778): os_win.c:34215: (5) 
winWrite2(\\TTDB.db3-journal) - Access is denied.
PID:02FB0036 TID:06B60006 SQLite error (778): statement aborts at 17: [UPDATE 
GlobalStatistics SET Value = '00:24:10',ResetValues = '00:24:10' WHERE 1 = 1  
AND Id = 5]
PID:02FB0036 TID:07FB038E CPU load: 100%   Change in heap memory: 523944 bytes
PID:02FB0036 TID:06B60006 SQLite error (2570): os_win.c:36492: (31) 
winDelete(\\TTDB.db3-journal) - A device attached to the system is not 
functioning.
PID:02FB0036 TID:06330356 CPU load: 100%   Change in heap memory: -674056 bytes
PID:02FB0036 TID:07FB038E CPU load: 100%   Change in heap memory: 534344 bytes
PID:02FB0036 TID:06B60006 SQLite error (14): os_win.c:36317: (31) 
winOpen(\\TTDB.db3-journal) - A device attached to the system is not 
functioning.
PID:02FB0036 TID:06330356 CPU load: 100%   Change in heap memory: -48928 bytes


As of now, this is the fix I have thought of

1.A Journal file gets created as a backup on every transaction, as in 
Update or Insert. This file gets deleted after the transaction is committed.

2.   I assumed that the journal file goes 'Read Only' sometimes because of 
which Delete operation fails.

3.   To fix it, every time I come across a SQL Lite error 14, I change the 
read only property of the Journal file.

Even after the changes, we still come across the error.
I would appreciate any kind of help.

P.S: This is a single thread doing the Read and update operation.

Regards,
Vijayeta

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-12-04 15:24 GMT+01:00 Gerry Snyder :

> It is always a good idea to put the arguments of [expr] in braces. That way
> they are byte-compiled.
>

​You mean like:
exec {swapon} (--noheadings} {--show}

-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Gerry Snyder
It is always a good idea to put the arguments of [expr] in braces. That way
they are byte-compiled.

Gerry

On Dec 4, 2017 6:33 AM, "Cecil Westerhof"  wrote:

> 2017-11-19 23:00 GMT+01:00 jungle boogie :
>
> > Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
> >
> >> I found the benefits for TCL/TK. But this is a SQLite mailing list, so
> not
> >> the right place to ask questions if it is not connected to SQLite also.
> >> What would be good resources for TCL/TK?
> >>
> >>
> > There's also a pretty active IRC room on freenode, it's #tcl.
> >
> > Let us know how your experiences go with tcl.
>
>
> ​I like it very much. It is a bit get used to, but I will manage I think.
> ;-)
>
> One think I like that global variables are not default exposed in
> procedures.
>
> I wrote something to help me choose which (of my about 30) teas I am going
> to brew. ;-)
>  ​
>
> ​I also wrote a program to store systems statistics in a SQLite database:
> ​#!/usr/bin/env tclsh
>
> ### Improvements
> # Get database from conf-file
>
>
> package require sqlite3
>
>
> proc getCPUTemp {} {
> if {1 != [regexp -all -line {^CPU_TEMP: +\+([0-9.]+)°C } [exec
> sensors] -> temp]} {
> error {Did not get exactly a single temperature line from [exec
> sensors] output}
> }
> return ${temp}
> }
>
> proc storeCPUTemp {} {
> storeMessage cpu-temp [getCPUTemp]
> }
>
> proc storeMessage {type message} {
> db eval "
>   INSERT INTO messages
>   (type, message)
>   VALUES
>   (:type, :message)
> "
> }
>
> proc storeSwap {} {
> storeMessage swap-usage [exec swapon --noheadings --show]
> }
>
> if {$argc != 1} {
> error "Error: ${argv0} DATABASE"
> }
> sqlite db  [lindex $argv 0]
> while {true} {
> after [expr 1000 * (60 - [clock format [clock seconds] -format
> %S])]
> set   currentSeconds [clock seconds]
> db transaction {
> storeCPUTemp
> # At the whole hour we save swap usage
> if {[clock format ${currentSeconds} -format %M] == "00"} {
> storeSwap
> }
> }
> }
> # Not really necessary because the above loop never ends
> # But I find this more clear and is robuster against change
> db close
>
> ​I am open for improvements.​
>
> --
> Cecil Westerhof
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Why Unicode is difficult

2017-12-04 Thread Jay Kreibich


Next, we can talk about how dates and times are simple and straight-forward.

 -j



> On Dec 4, 2017, at 7:08 AM, Simon Slavin  wrote:
> 
> Every so often someone asks on this list for Unicode to be handled properly.  
> I did it myself.  Then other people have to explain how hard this is.  So 
> here’s an article which, after introductory material, discusses the hard 
> questions in Unicode:
> 
> 
> 
> Are two strings the same?
> How long is a string?
> How do you sort things in alphabetical order?
> 
> The first and third questions are requirements for implementing COLLATE in 
> SQLite.  And the fact that the second question is a difficult one emphasises 
> that one shouldn’t take Unicode as simple.
> 
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-11-19 23:00 GMT+01:00 jungle boogie :

> Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
>
>> I found the benefits for TCL/TK. But this is a SQLite mailing list, so not
>> the right place to ask questions if it is not connected to SQLite also.
>> What would be good resources for TCL/TK?
>>
>>
> There's also a pretty active IRC room on freenode, it's #tcl.
>
> Let us know how your experiences go with tcl.


​I like it very much. It is a bit get used to, but I will manage I think.
;-)

One think I like that global variables are not default exposed in
procedures.

I wrote something to help me choose which (of my about 30) teas I am going
to brew. ;-)
 ​

​I also wrote a program to store systems statistics in a SQLite database:
​#!/usr/bin/env tclsh

### Improvements
# Get database from conf-file


package require sqlite3


proc getCPUTemp {} {
if {1 != [regexp -all -line {^CPU_TEMP: +\+([0-9.]+)°C } [exec
sensors] -> temp]} {
error {Did not get exactly a single temperature line from [exec
sensors] output}
}
return ${temp}
}

proc storeCPUTemp {} {
storeMessage cpu-temp [getCPUTemp]
}

proc storeMessage {type message} {
db eval "
  INSERT INTO messages
  (type, message)
  VALUES
  (:type, :message)
"
}

proc storeSwap {} {
storeMessage swap-usage [exec swapon --noheadings --show]
}

if {$argc != 1} {
error "Error: ${argv0} DATABASE"
}
sqlite db  [lindex $argv 0]
while {true} {
after [expr 1000 * (60 - [clock format [clock seconds] -format %S])]
set   currentSeconds [clock seconds]
db transaction {
storeCPUTemp
# At the whole hour we save swap usage
if {[clock format ${currentSeconds} -format %M] == "00"} {
storeSwap
}
}
}
# Not really necessary because the above loop never ends
# But I find this more clear and is robuster against change
db close

​I am open for improvements.​

-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Why Unicode is difficult

2017-12-04 Thread Simon Slavin
Every so often someone asks on this list for Unicode to be handled properly.  I 
did it myself.  Then other people have to explain how hard this is.  So here’s 
an article which, after introductory material, discusses the hard questions in 
Unicode:



Are two strings the same?
How long is a string?
How do you sort things in alphabetical order?

The first and third questions are requirements for implementing COLLATE in 
SQLite.  And the fact that the second question is a difficult one emphasises 
that one shouldn’t take Unicode as simple.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users