1

When doing this on Windows (sqlite3.version is 2.6.0, sqlite3.sqlite_version is 3.23.1):

import sqlite3, datetime
db = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)
c = db.cursor()
c.execute('CREATE TABLE mytable (id integer, date timestamp)')
c.execute('INSERT INTO mytable VALUES (1, ?)', (datetime.datetime(2018,1,1,12,11,29),))

c.execute('CREATE INDEX id1 ON mytable(JULIANDAY(date))')

it works (the fact of having an INDEX on JULIANDAY(date) and not on date is useful because of this question+answer).

When doing the same on Linux (sqlite3.version is 2.6.0, sqlite3.sqlite_version is 3.8.2), I get:

sqlite3.OperationalError: near "(": syntax error

Is creating an INDEX on JULIANDAY(date) in this version?

Basj
  • 41,386
  • 99
  • 383
  • 673

1 Answers1

3

According to the documentation, the ability to create indexes on expressions was introduced in SQLite 3.9.0 - so you won't be able to use it in the 3.8.2 version you have installed on your linux machine.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • 1
    Linked question: https://stackoverflow.com/questions/49820873/upgrade-pythons-sqlite3-on-debian – Basj Apr 18 '18 at 18:56