As lots of code seems to be copy-pasted from Django's SQLite backend, what about deduplicate it by extending instead of copy-pasting?
This way, bugfixes in SQLite upstream would propagate, and would be clearer what code is new and what is Django's one.