db.py 文件源码

python
阅读 90 收藏 0 点赞 0 评论 0

项目:birdnet 作者: cyysu 项目源码 文件源码
def _py2sql(self, val):
        r"""
        Work around a couple of problems in SQLite that maybe pysqlite
        should take care of: give it True and False and it thinks
        they're column names; give it Unicode and it tries to insert
        it in, possibly, ASCII.

            >>> meth = SqliteDB(db='nonexistent')._py2sql
            >>> [meth(x) for x in [True, False, 1, 2, 'foo', u'souffl\xe9']]
            [1, 0, 1, 2, 'foo', 'souffl\xc3\xa9']

        """
        if val is True: return 1
        elif val is False: return 0
        elif isinstance(val, unicode): return val.encode(self.encoding)
        else: return val
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号