Home
Blog
About
Database administration
Operating systems
Development
Links
Following require login:
ScratchPad
Note that the sqlite3 executable cannot access encrypted databases - that facility is a cost option.
Details of System.Data.SQLite can be found here
Note that this .NET assembly can access encrypted SQLite databases.
This is useful if you are using Unix, on Windows try using Cygwin.
$ echo ".dump" | ./sqlite3 p:/Data/Listener.sqlite | ./sqlite3 Listener1.sqlite
This example converts a GMT datetime into datetime in the local timezone by adding (or subtracting if diffseconds is negative) the difference from GMT in seconds.
-- Server time when snapshot was taken ,datetime( julianday( c.Dttm ) + ( utc.DiffSeconds / 86400.0) ) as ServerDttm
Where c.Dttm is a column with datatype DateTime and DiffSeconds is numeric.
The julianday function returns a fractional number of days, we convert DiffSeconds to a fractional number of days by dividing by 86400.0
Note that the decimal value is required to force SQLite to use floating point arithmetic.
This example formats a process runtime (measured in seconds) as Days,Hours,Minutes and seconds.
-- Uptime in format DDDD:HH:MI:SS. Substr is used to left pad days with zeroes ,substr('0000' || cast( c.RunSeconds/86400 as varchar ) || ':' || time( ( c.RunSeconds - ( ( c.RunSeconds/86400)*86400 ) ), 'unixepoch' ), -13, 13 ) as Uptime
There is no LPAD or equivalent in SQLite so we use substr.