c# - 通过网络流访问sqlite数据库

标签 c# database sqlite networking

我想知道是否有一种方法可以将网络流视为文件。我可能是错的,但我将文件视为字节数组列表。当您在Windows中打开一个文件并向其写入时,我相信您正在向该文件(数组列表)插入字节。

我正在创建一个程序,并使用 SQLite 数据库部署它。我还创建了客户端版本,它连接到网络上的数据库文件。

为了让用户连接到数据库文件,他们需要提供凭据才能访问该数据库中的数据。 我希望他们能够在无需输入该信息的情况下进行连接。

我一直在想的事情:

  • 使用 sql server 部署我的应用程序。 (使用 SQL Server 部署应用程序并不容易,它会默默地安装服务器、启用 tcp 连接以及实现此目的所需的所有配置。此外,安装大约需要 7 分钟,而 sqlite 只需要不到 20 秒!

  • 我正在使用 WCF 与服务器通信,这样我就可以为我计划使用的每个查询创建一个函数。因此,如果我想从产品中选择 *,我可以在 WCF 服务上调用方法 SelectAllFromProducts()...(这里我有点重新发明轮子。)此外,这样做的好处是我的查询会很多我相信更快。 Sqlite 是无服务器的,因此如果您计划查找产品中产品名称类似于“foo”的所有项目,那么如果您考虑一下,计算机将必须通过网络访问数据库中的所有记录。如果本地计算机执行此操作并将少量结果发送到客户端,则会更快。

最佳答案

我认为通过网络使用 Sqlite 不是一个好主意。我目前正在使用 Sqlite,但作为本地文件系统数据库。

在客户端服务器架构中,您最好使用一些 RDBMS 而不是 SQLite

Client/Server Applications

If you have many client programs accessing a common database over a network, you should consider using a client/server database engine instead of SQLite. SQLite will work over a network filesystem, but because of the latency associated with most network filesystems, performance will not be great. Also, the file locking logic of many network filesystems implementation contains bugs (on both Unix and Windows). If file locking does not work like it should, it might be possible for two or more client programs to modify the same part of the same database at the same time, resulting in database corruption. Because this problem results from bugs in the underlying filesystem implementation, there is nothing SQLite can do to prevent it.

请查看此链接 Appropriate use for Sqlite并跳转到部分

Situations Where Another RDBMS May Work Better

关于c# - 通过网络流访问sqlite数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10154397/

相关文章:

java - Hibernate 在一对多映射上添加 where 子句

c# - 删除可选的最后一个括号

c# 将新对象添加到对象上下文返回 "error occurred while updating the entries",主键的重复条目

c# - 使用本地数据库时存储空间不足错误

android - 我想通过给定时间限制来更新来自服务器的数据

c - 打印 sqlite3_exec 错误消息导致 C 中的段错误

C# WebBrowser 控件 - 使用 InvokeMember ("Click"提交表单不工作)

c# - 更好的技术 : Reading Data in a Thread

iphone - iPhone 上 SQLite 的用户定义函数

java - 如果多次打开 sqlite 则不会检索到数据