使用套接字通过C程序执行SQL查询 [英] Execute sql query through a c program using sockets

查看:109
本文介绍了使用套接字通过C程序执行SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


好吧,我想到了想办法用C语言编写一个Client程序,该程序以sql查询作为用户输入,然后将结果取回屏幕.
现在,如果数据库位于远程计算机上,我可以通过套接字执行相同的操作以在远程服务器上执行查询并在客户端屏幕上获取结果.
关于此的任何编程示例都可以帮助我.
您可以提供给我的任何示例示例,或任何明确描述这种情况的特定文章.

谢谢.

Hi,
Well i thought of figuring out a way to write a Client program in C which takes an sql query as the user input and then fetches back the result to the screen.
Now if the database is on a remote machine, can i do the same thing through sockets to execute the query on the remote server and get back the results on the client screen.
Any programmatic examples on this that you could help me with.
Any sample example you could please provide me or any particular article which explicitly describes this scenario.

Thank you.

推荐答案

如果让我们知道您使用的是哪个数据库,则可以获得更好的帮助.因为大多数数据库(我已经学习的所有数据库都提供了此功能,所以我不了解那些我没有学过的数据库)提供了与数据库服务器连接的API.因此,请执行以下操作:
1.在google上搜索与数据库连接的说明.
2.如果您可以找到但仍然有问题,请通知我们.
3.如果找不到适合您客户的基于服务器的解决方案,请与您的数据库提供商联系.
4.如果他们根本不提供,那么您可能需要创建基于套接字的客户端.在这种情况下,您还必须了解如何开发基于套接字的客户端服务器应用程序
You can get better help if you let us know what database you are using. Because most of the databases(all the databases I have already learned provide this, I don''t know about those database which i didn''t learn) provide API to connect with Database Server. So do the following:
1. Search on google for the instruction to connect with your database.
2. If you can find but still having problem then let us know.
3. If you cannot find the server based solution for your client then please communicate with your database provider.
4.If they dont provide at all, then you might need to create the socket based client. In that case, you would also have to learn about how to develop socket based client server application


您不需要套接字即可执行此操作.数据库库具有自己的客户端接口,可以为您执行任务.如果您使用不同类型的数据库,则几乎没有可用的抽象层.
好吧,您可以使用以下任何一个库:
1. SOCI-数据库抽象库 [ ^ ]
2. POCO库数据库抽象层 [ ^ ]
这些为从C ++以统一的方式处理不同的数据库提供了抽象.我使用过SOCI,效果很好.
我在以下位置使用Visual Studio 2008建立了SOCI的Windows版本供我使用.您可以根据需要使用它.它使用sqlite3作为数据库.
我的Visual Studio 2008的SOCI 3.1版本. [
You do not need sockets to do this. Database libraries have their own client interfaces that do the task for you. There are few abstraction layer that can be used if you are using different type of databases.
Well you can use any of the below libraries:
1. SOCI - Database Abstraction Library[^]
2. POCO Library Database abstraction layer[^]
These provide abstraction for dealing with different databases in a unified way from C++. I have used SOCI and it work great.
I have a windows build for SOCI using visual studio 2008 in the following location for my use. You can use it if you wish. It uses sqlite3 as database.
My SOCI 3.1 Build for Visual Studio 2008.[^]
Let me know if you need any help.


这篇关于使用套接字通过C程序执行SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆