Discuz! BBS

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 751|回复: 0

Python安装Sqlite3

[复制链接]

255

主题

364

帖子

2438

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2438
发表于 2023-7-10 17:38:27 | 显示全部楼层 |阅读模式
1)先下载Sqlite3:
https://www.sqlite.org/download.html
2)编译:
configure --prefix=/usr/local/sqlite
make -j 4 & make install

ref:https://www.pianshen.com/article/7260586724/
Compiling The Command-Line Interface
A build of the command-line interface requires three source files:
  • sqlite3.c: The SQLite amalgamation source file
  • sqlite3.h: The header files that accompanies sqlite3.c and defines the C-language interfaces to SQLite.
  • shell.c: The command-line interface program itself. This is the C source code file that contains the definition of the main() routine and the loop that prompts for user input and passes that input into the SQLite database engine for processing.
All three of the above source files are contained in the amalgamation tarball available on the download page.
To build the CLI, simply put these three files in the same directory and compile them together. Using MSVC:
cl shell.c sqlite3.c -Fesqlite3.exe
On Unix systems (or on Windows using cygwin or mingw+msys) the command typically looks something like this:
gcc shell.c sqlite3.c -lpthread -ldl -lm -o sqlite3
The pthreads library is needed to make SQLite threadsafe. But since the CLI is single threaded, we could instruct SQLite to build in a non-threadsafe mode and thereby omit the pthreads library:
gcc -DSQLITE_THREADSAFE=0 shell.c sqlite3.c -ldl -lm -o sqlite3
The -ldl library is needed to support dynamic loading, the sqlite3_load_extension() interface and the load_extension() SQL function. If these features are not required, then they can be omitted using SQLITE_OMIT_LOAD_EXTENSION compile-time option:
gcc -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION shell.c sqlite3.c -o sqlite3
One might want to provide other compile-time options such as
In order to see extra commentary in EXPLAIN listings, add the -DSQLITE_ENABLE_EXPLAIN_COMMENTS option. Add -DHAVE_READLINE and the -lreadline and -lncurses libraries to get command-line editing support. One might also want to specify some compiler optimization switches. (The precompiled CLI available for download from the SQLite website uses "-Os".) There are countless possible variations here. A command to compile a full-featured shell might look something like this:
gcc -Os -I. -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS4 \   -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 \   -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS \   -DHAVE_READLINE \   shell.c sqlite3.c -ldl -lm -lreadline -lncurses -o sqlite3
The key point is this: Building the CLI consists of compiling together two C-language files. The shell.c file contains the definition of the entry point and the user input loop and the SQLite amalgamation sqlite3.c contains the complete implementation of the SQLite library.
Building A Windows DLL
To build a DLL of SQLite for use in Windows, first acquire the appropriate amalgamated source code files, sqlite3.c and sqlite3.h. These can either be downloaded from the SQLite website or custom generated from sources as shown above.
With source code files in the working directory, a DLL can be generated using MSVC with the following command:
cl sqlite3.c -link -dll -out:sqlite3.dll
The above command should be run from the MSVC Native Tools Command Prompt. If you have MSVC installed on your machine, you probably have multiple versions of this Command Prompt, for native builds for x86 and x64, and possibly also for cross-compiling to ARM. Use the appropriate Command Prompt depending on the desired DLL.
If using the MinGW compiler, the command-line is this:
gcc -shared sqlite3.c -o sqlite3.dll  (sqlite3.so)
注意可以直接从16G上拷贝原文件:    到以下:    除了16G原有的目录复制,还要拷 /usr/lib/python3.6/lib-dynload/_sqlite3_.....36m.....arm-......so   有这个文件基本就行了,具体这个文件在哪自己到原盘去找。
还有/usr/local/lib/python3.6/lib-dynload/_sqlite3_......36m.......arm-......so  这个位置这个文件也要有即/usr/lib  和/usr/local/lib都要有,否则找不到报错。
再一个就是看报错,把.so文件拷到报错文件找得着的地方。

sqlite-amalgamation-3420000.zip (2.52 MB, 下载次数: 152)

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-4-16 16:12 , Processed in 0.017167 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表