try to use bool/booleans with adapter/converter, but...

henk-jan ebbers <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Greetings,

I am trying to store booleans in SQLite with pysqlite.
I made a table with this SQL:
    CREATE TABLE partner (
        idpartner   VARCHAR(35)                 NOT NULL,
        active       BOOLEAN,
        name       VARCHAR(256),
       PRIMARY KEY (idpartner)
       )
(checked: in SQLite field 'active' is indeed type BOOLEAN)

I need to use converters/adapters to use (from documentation). So:

    def adapter4bool(boolfrompython):
        return int(boolfrompython)

    def converter4bool(intfromdb):
        return bool(intfromdb)

    sqlite.register_adapter(bool,adapter4bool)
    sqlite.register_converter('BOOLEAN',converter4bool)

    conn = sqlite.connect(database, detect_types=sqlite.PARSE_DECLTYPES)

(and I subclass (sqlite.Connection with the 'factory' paramaeter, but I
don't think this matters)

But somehow this does not work.
I get 'Operation Error: no such column: True'
It seems that my adapter/convert-functions are never executed

What am I doing wrong?

Kind regard,
Henk-Jan Ebbers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.