gpt4 book ai didi

c++ - sqlite C++ 和无符号整数键

转载 作者:搜寻专家 更新时间:2023-10-31 01:48:46 60 4
gpt4 key购买 nike

我正在尝试迁移到 SQLite。在我的 C++ 程序中,我使用 unsigned int key 来存储 id。当我将数据从 C++ 程序序列化到 SQLite,然后将其反序列化或浏览数据库时,我在列中看到负值(带符号)。

我使用此函数在序列化上绑定(bind) unsigned ints:

sqlite3_bind_int(stmt, 1, key);

键的表列在创建时声明为 INT。也许这是我的错误?

有什么建议可以正确地将 unsigned ints 序列化到 SQLite 中并在不做任何更改的情况下加载回来吗?

最佳答案

SQLite 的类型系统不支持无符号整数。但您可以使用 sqlite3_bind_int64 代替:unsigned int(假设它是 32 位)可以无损地转换为 int64_t

关于c++ - sqlite C++ 和无符号整数键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17305811/

60 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com