SQLite 支持“datareader”吗?
我正在尝试在 SQLite 中使用数据读取器,但无法在我拥有的文档中找到任何内容(Kreibich 的“使用 SQLite”)。
有人可以告诉我它是否受支持以及在哪里可以找到一些示例?
I'm trying to use a datareader in SQLite, but am unable to find anything in the docs I have ("Using SQLite" by Kreibich).
Can someone tell me if it's supported and where I can find some examples?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您只需要获取 System.Data.SQLite 即可。
它有两种变体,一种内置 SQLite,另一种要求您还提供单独的本机 sqlite DLL。
Yes, you just need to get yourself System.Data.SQLite.
It comes in two variants, one that has SQLite built-in, and another which requires that you also ship a separate native sqlite DLL.
sqlite api有一个逻辑上等同于.net阅读器的概念。这意味着,您发出查询,然后根据需要迭代读取数据。这会使内存保持较低水平,因为您没有将完整的结果集拉入内存。
首先,看一下其他包装器,例如 fmdb。
这是使用 iPhone 内部的 c api 的等效方法。您通过传递 sql 查询(sqlite 在幕后解析)来准备语句,然后调用相当于 .net reader read 方法的步骤。您可以像 .net 数据阅读器一样阅读列。请注意,此示例准备并完成(清理)。更有效的方法是保存准备好的语句,然后调用重置以避免让 sqlite 一遍又一遍地解析查询。
the sqlite api has a concept which is logically equivalent to the .net reader. which means, you issue a query and then iterate read data as needed. that keeps memory low as your not pulling the complete result set into memory.
first of all, take a look at other wrappers like fmdb.
here's the equivalent using the c api inside of iPhone. You prepare the statement by passing the sql query (sqlite parses under the cover), then you call step which is the equivalent to the .net reader read method. The you read columns just like the .net data reader. Note that this example prepares and finalizes (cleans up). A more efficient approach is to save the prepared statement and then call reset to avoid having sqlite parse the query over and over.