社区
CGI
帖子详情
sqlite3_step() 与sqlite3_exec()的区别
youxin2012
2012-10-26 04:02:32
偶知道 sqlite3_step() 与sqlite3_exec() 都可以执行sql语句, 想知道两者用起来的区别在哪?
除了 sqlite3_step() 在执行之前需要调用sqlite3_perpare(),之后需要sqlite3_finalize()
谢谢
...全文
4017
1
打赏
收藏
sqlite3_step() 与sqlite3_exec()的区别
偶知道 sqlite3_step() 与sqlite3_exec() 都可以执行sql语句, 想知道两者用起来的区别在哪? 除了 sqlite3_step() 在执行之前需要调用sqlite3_perpare(),之后需要sqlite3_finalize() 谢谢
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
云敛容
2014-07-28
打赏
举报
回复
sqlite3_exec() 就是把你提到的三个函数结合在了一起:sqlite3_step(), sqlite3_perpare(), sqlite3_finalize()。 然后提供一个回调函数进行结果的处理。
SQlite
数据库在VC中的使用
EXPORTS
sqlite
3_aggregate_context
sqlite
3_aggregate_count
sqlite
3_bind_blob
sqlite
3_bind_double
sqlite
3_bind_int
sqlite
3_bind_int64
sqlite
3_bind_null
sqlite
3_bind_parameter_count
sqlite
3_bind_parameter_index
sqlite
3_bind_parameter_name
sqlite
3_bind_text
sqlite
3_bind_text16
sqlite
3_busy_handler sqlit
sqlite
3在Visual studio 2012下的编译
Visual studio 2012 下
sqlite
3的工程文件,生成32或64位的
sqlite
3库 This page explains how to compile
SQLite
with Microsoft Visual Studio.NET (aka VS.NET). Download Download and unzip the file
sqlite
_source.zip (or
sqlite
-amalgamation-x_x_x_x.zip). Do not use the .tar.gz files because they have not been pre-processed for use with Windows. Create a starter DLL project File > New > Project. Under Project Types, select Visual C++ Projects and then Win32. Choose the project template "Win32 Project". Give the project a name and click OK. When the "Win32 Application Wizard" appears, choose Application Settings. set the Application Type to DLL and check the box that says "Empty project". Click Finish. You now have a blank DLL project. Add the
SQLite
files to the project Project > Add Existing Item. Add all the .c and .h files that you unzipped, except for: tcl
sqlite
.c and shell.c. Note: You may add tcl
sqlite
.c and shell.c, but then you have to define the preprocessor-symbol NO_TCL. Click Project -> Properties, navigate to the C/C++-folder and choose "Preprocessor". In the field that says "Preprocessor definitions" add NO_TCL to the existing string, separated by a semicolon. Under "Code Generation" for "Runtime Library" make sure to pick static linking. /MTd (release) or /MTd (debug) Make a .DEF file A .def file should be placed in the project directory. Get the def file by downloading the zipped
sqlite
DLL file under the "Precompiled Binaries For Windows" in the download page. Add the
sqlite
[3].def file to the project. Under Project > Properties navigate to the Linker folder and choose "Input". In the field that says "Module Definition File" type
sqlite
[3].def. NOTE: You have to do this twice, once for the Debug configuration and once for the Release configuration. Compile! The next 3
step
s maybe be required by some. I was able to build the DLL and produce a .lib file only following the above 12
step
s. for VS 2005. In order to build the lib file so that an application can link against the
sqlite
[3].dll you will need to add a
step
to the post-build event. Right click on Project, select Properties, expand Build Events and type "LIB /DEF:\
sqlite
[3].def" into the Command line field, both for debug and release configurations, where is the location to the file
sqlite
[3].def. To compile 3.3.7(this may apply to other versions too), I had to do this extra
step
: Add the project directory to the include path, here's how to do it in details: Under Project > Properties navigate to the C/C++ folder and choose "General", In the field "Additional Include Directories" type "."(a single dot, which is the current directory) Repeat for each configuration (debug/release/Win32/x64). To compile 3.6.14.1 (maybe others too), I also had to: Go to Project > Properties. Open the C/C++ then Preprocessor folder. Add "
SQLITE
_ENABLE_COLUMN_METADATA" to the list of preprocessor definitions. Repeat for each configuration (debug/release/Win32/x64). How to make the
SQLITE
.EXE command-line utility There are some slight changes if you wanted to build the
sqlite
.exe command-line utility, instead of the DLL. To do that, when you're creating the project and you get to the "Win32 Application Wizard", choose "Console Application" instead of "DLL". Then, when you are adding files to the project, also add shell.c. Finally, don't include the .DEF file. The sqllite def for version 2 is. EXPORTS
sqlite
_open
sqlite
_close
sqlite
_
exec
sqlite
_last_insert_rowid
sqlite
_error_string
sqlite
_interrupt
sqlite
_complete
sqlite
_busy_handler
sqlite
_busy_timeout
sqlite
_get_table
sqlite
_free_table
sqlite
_mprintf
sqlite
_vmprintf
sqlite
_
exec
_printf
sqlite
_
exec
_vprintf
sqlite
_get_table_printf
sqlite
_get_table_vprintf
sqlite
_freemem
sqlite
_libversion
sqlite
_libencoding
sqlite
_changes
sqlite
_create_function
sqlite
_create_aggregate
sqlite
_function_type
sqlite
_user_data
sqlite
_aggregate_context
sqlite
_aggregate_count
sqlite
_set_result_string
sqlite
_set_result_int
sqlite
_set_result_double
sqlite
_set_result_error
sqlite
Malloc
sqlite
Free
sqlite
Realloc
sqlite
_set_authorizer
sqlite
_trace
sqlite
_compile
sqlite
_
step
sqlite
_finalize
sqlite
_progress_handler
sqlite
_reset
sqlite
_last_statement_changes
sqlite
3_
step
()与
sqlite
3_
exec
()
区别
:
sqlite
_
step
()在执行select时使用,因为查询到的结果可能会有多条,所以只要返回值是
SQLITE
_ROW,就要一直循环去获取结果; 而
sqlite
3_
exec
()则是对insert、update,delete等执行后只影响数据库中的内容的操作时使用。 ...
sqlite
3_prepare_v2,
sqlite
3_
step
如果既不想写回调函数,又想避免
sqlite
3_get_table之后麻烦 的一维数组遍历,那么利用
sqlite
3_prepare_v2执行sql select语句,让后
sqlite
3_
step
遍历select执行的返回结果是一个非常方便的solution. 当然,你必须要明白
sqlite
3_prepare_v2不仅仅能够执行table的query selection,也能方便地进行sql Delete, Insert, Update等其他一些操作。它能帮你把sql语句的执行操作变的更加优雅。 i...
SQLLite (三):
sqlite
3_prepare_v2,
sqlite
3_
step
如果既不想写回调函数,又想避免
sqlite
3_get_table之后麻烦的一维数组遍历,那么利用
sqlite
3_prepare_v2执行sql select语句,让后
sqlite
3_
step
遍历select执行的返回结果是一个非常方便的solution. 当然,你必须要明白
sqlite
3_prepare_v2不仅仅能够执行table的query selection,也能方便地进行sql Del
CGI
2,204
社区成员
4,518
社区内容
发帖
与我相关
我的任务
CGI
Web 开发 CGI
复制链接
扫一扫
分享
社区描述
Web 开发 CGI
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章