#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''It applies the SQLite-specific stuff to :mod:`mosql.util`.

The usage:

::

    import mosql.sqlite

If you want to patch again:

::

    mosql.sqlite.patch()

It will replace the functions in :mod:`mosql.util` with its functions.
'''

def format_param(s=''):
    '''It formats the parameter of prepared statement.'''
    return ':%s' % s if s else '?'

import mosql.util

def patch():
    '''Applies the SQLite-specific functions again.

    .. versionadded:: 0.10
    '''
    mosql.util.format_param = format_param

patch() # patch it when load this module

if __name__ == '__main__':
    import doctest
    doctest.testmod()

@@ -397,16 +397,225 @@
 se '?'%0A%0A
+def stringify_bool(b):%0A    '''It stringifies the bool.%0A%0A    SQLite does not take %60%60TRUE%60%60 and %60%60FALSE%60%60 literals, only integers, so we%0A    return %60%601%60%60 and %60%600%60%60 instead.%0A    '''%0A    return '1' if b else '0'%0A%0A
 import m
@@ -768,16 +768,63 @@
 at_param
+%0A    mosql.util.stringify_bool = stringify_bool
 %0A%0Apatch(

Patch stringify_bool for SQLite