file seek

seek( offset[, whence])
offset: 位移量
whence: 從哪個位置

  • 0 - absolute file positioning
  • 1 - seek relative to the current position
  • 2 - seek relative to the file's end
Reference: Python file object

GLOB and LIKE

LIKE 是大小寫有分的可以用  PRAGMA case_sensitive_like=ON; 來讓LIKE變成大小寫不分,但是只限於latin1 characters, 反之GLOB則是大小寫不分
_ 比對任一字元
%比對任意數量的字元

field GLOB pattern => glob(pattern, field)
field LIKE pattern => like(pattern, field)
函數引數位置與敘述位置剛好相反

user-defined function for GLOB/LIKE/REGEXP
GLOB => glob()
LIKE => like()
REGEXP => regexp()

APSW

Connection.createscalarfunction(name, callable[, numargs=-1])

Registers a scalar function. Scalar functions operate on one set of paramaters once.
Parameters:
  • name – The string name of the function. It should be less than 255 characters
  • callable – The function that will be called
  • numargs – How many arguments the function takes, with -1 meaning any number

SQLite date/time

SQLite Date and Time

Five date and time functions are available, as follows:
  1. date( timestring, modifier, modifier, ...)
  2. time( timestring, modifier, modifier, ...)
  3. datetime( timestring, modifier, modifier, ...)
  4. julianday( timestring, modifier, modifier, ...)
  5. strftime( format, timestring, modifier, modifier, ...) 
A time string can be in any of the following formats:
  1. YYYY-MM-DD
  2. YYYY-MM-DD HH:MM
  3. YYYY-MM-DD HH:MM:SS
  4. YYYY-MM-DD HH:MM:SS.SSS
  5. YYYY-MM-DDTHH:MM
  6. YYYY-MM-DDTHH:MM:SS
  7. YYYY-MM-DDTHH:MM:SS.SSS
  8. HH:MM
  9. HH:MM:SS
  10. HH:MM:SS.SSS
  11. now
  12. DDDD.DDDD 
The time string can be followed by zero or more modifiers that alter the date or alter the interpretation of the date. The available modifiers are as follows.
  1. NNN days
  2. NNN hours
  3. NNN minutes
  4. NNN.NNNN seconds
  5. NNN months 
  6. NNN years 
  7. start of month
  8. start of year
  9. start of week (withdrawn -- will not be implemented)
  10. start of day
  11. weekday N 
  12. unixepoch
  13. localtime
  14. utc 
其中Time String 主要以"-"作為年月日的分隔符號,若是不同的分隔符號用
core function::replace("yyyy/mm/dd", "/", "-")去修改

Some example

SELECT * FROM totp WHERE wk = '1982-05-20'  /* 指定某一天 */

SELECT * FROM totp WHERE wk BETWEEN '1980-05-20' AND '1980-05-26'  /* range */