简体   繁体   English

如何在Objective-C iPhone应用程序上从SQLite数据库发布和获取数据?

[英]How to post and get data from SQLite database on objective-c iphone app?

I am new for Apple programming or objective-c. 我是Apple编程或Objective-c的新手。 I have a task to create an app which can post and get data from SQLite database which is in remote server. 我有一个任务来创建一个应用程序,该应用程序可以从远程服务器中的SQLite数据库发布和获取数据。 We have the ip address of server and we can access to that database file. 我们有服务器的IP地址,我们可以访问该数据库文件。 Can you give me a little example code that how can i post and get data from SQlite server ? 您能否给我一些示例代码,我该如何从SQlite服务器发布数据并获取数据?

There are multiple options: 有多种选择:

  1. You download that sqlite file (if it is not too large), once you have it in disk, you can use sqlite queries to fetch data. 您下载该sqlite文件(如果不是太大),一旦将其保存在磁盘中,就可以使用sqlite查询来获取数据。 Then you do not need to get and post data from sever and your app can act as an offline app once it has data. 然后,您无需从服务器获取和发布数据,并且一旦应用程序有了数据,您的应用程序就可以充当离线应用程序。

  2. Preferred way with respect to your questions : You will have to create a webservice that will interact with the sqlite file. 关于您的问题的首选方式 :您将必须创建一个将与sqlite文件进行交互的Web服务。 You will have to install odbc drivers and create oledb connection to your sqlite file in the web service. 您将必须安装odbc驱动程序并在Web服务中创建到sqlite文件的oledb连接。 and then you may do normal get and post as you would for a web service. 然后您可以像进行Web服务一样进行正常的获取和发布。

  3. If you wish to access SQLite file over the network, then do remeber that sqlite file is a flat file database and only one user can access to it at one point in time . 如果您希望通过网络访问SQLite文件, 请记住sqlite文件是一个平面文件数据库,并且一个时间点只有一个用户可以访问它 So a distibuted app trying to access the file may cause issues. 因此,发布应用程序尝试访问该文件可能会导致问题。 Refer SQlite Network Documentation 请参阅SQlite网络文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM