0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

移植sqlite交叉编译sqlite3

嵌入式加油站 来源:嵌入式加油站 2023-07-10 11:29 次阅读

【前言】

SQLite是遵守ACID的关联式数据库管理系统,它包含在一个相对小的C库中, 是一款轻量轻级数据库。它是D.RichardHipp建立的公有领域项目。不像常见的客户-服务器范例,SQLite引擎不是个程序与之通信的独立进程,而是连接到程序中成为它的一个主要部分。

所以主要的通信协议是在编程语言内的直接API调用。这在消耗总量、延迟时间和整体简单性上有积极的作用。整个数据库(定义、表、索引和数据本身)都在宿主主机上存储在一个单一的文件中。它的简单的设计是通过在开始一个事务的时候锁定整个数据文件而完成的。SQLite非常适合嵌入式系统应用。所以我们的openwrt用此数据库

【实操---交叉编译sqlite】

获取sqlite源码(如果是已经编译过的旧工程可跳过此步骤)

解压
tar vzxf sqlite-autoconf-3410000.tar.gz
cd sqlite-autoconf-3410000/
查看编译说明
cat README.txt
查阅Makefile
cat Makefile
创建编译目标目录
mkdir mips_build
编译前配置
./configure CC=mipsel-openwrt-linux-gcc --host=mipsel-openwrt-linux --prefix=/home/fan/work/sqlite-autoconf-3410000/mips_build/
编译sqlite3
make
make install

编译结果
ls mips_build/
binincludelibshare
bin ---- 存放可以执行文件 sqilte3 可传到开发板执行
inlcude ---- 供外部调到的头文件,声明了相关sqlite库接口
lib ---- sqlite动态连接库
share -- sqtlie相关共享库
把库加入到用户源码工程,工程中就用使用sqlite接口了
cp -rf ./* ~/openwrt_21.02.0_mt76x8_jotale_source/package/omj_gateway/extra-libs/mips/sqlite3/如果是cmake工程,在.cmake文件中添加sqlite3--include和lib目录路径
-- EXTRA_INC_PATH=../../extra-libs/mips/sqlite3/include
-- EXTRA_LIB_PATH=../../extra-libs/mips/sqlite3/lib

【实操--在开发板上运行】
确认开发板与电脑开发机在同一局域网下
scp bin/sqlite3root@192.168.3.176:/root/
按提示输入开发板密码
root@192.168.3.176's password:
等待传输完成sqlite3 100% 7297KB 164.7KB/s 00:44


在开发执行sqlite3
到root目录,因为刚才传入的是root目录
cd /root
查看sqlite3属性
ls -la
...
-rwxr-xr-x 1 root root 7472168 Jul4 13:47 sqlite3 //开发板用的root应用,可以看到在开发板,已经有了可执行权
...
运行sqlite3
./sqlite3SQLite version 3.41.0 2023-02-21 1837Enter ".help" for usage hints.Connected to a transient in-memory database.Use ".open FILENAME" to reopen on a persistent database.
查看sqlite使用方法, 数据库使用太多内容,本文是讲不完的,有用到sqlte朋友,自行补课吧。
sqlite> .help
.auth ON|OFF Show authorizer callbacks
.backup ?DB? FILE Backup DB (default "main") to FILE
.bail on|off Stop after hitting an error.Default OFF
.binary on|off Turn binary output on or off.Default OFF
.cd DIRECTORY Change the working directory to DIRECTORY
.changes on|off Show number of rows changed by SQL
.check GLOB Fail if output since .testcase does not match
.clone NEWDB Clone data into NEWDB from the existing database
.connection [close] [#]Open or close an auxiliary database connection
.databases List names and files of attached databases
.dbconfig ?op? ?val? List or change sqlite3_db_config() options
.dbinfo ?DB? Show status information about the database
.dump ?OBJECTS? Render database content as SQL
.echo on|off Turn command echo on or off
.eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN
.excel Display the output of next command in spreadsheet
.exit ?CODE? Exit this program with return-code CODE
.expert EXPERIMENTAL. Suggest indexes for queries
.explain ?on|off|auto? Change the EXPLAIN formatting mode.Default: auto
.filectrl CMD ... Run various sqlite3_file_control() operations
.fullschema ?--indent? Show schema and the content of sqlite_stat tables
.headers on|off Turn display of headers on or off
.help ?-all? ?PATTERN? Show help text for PATTERN
.import FILE TABLE Import data from FILE into TABLE
.imposter INDEX TABLE Create imposter table TABLE on index INDEX
.indexes ?TABLE? Show names of indexes
.limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT
.lint OPTIONS Report potential schema issues.
.load FILE ?ENTRY? Load an extension library
.log FILE|off Turn logging on or off.FILE can be stderr/stdout
.mode MODE ?OPTIONS? Set output mode
.nonce STRING Suspend safe mode for one command if nonce matches
.nullvalue STRING Use STRING in place of NULL values
.once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE
.open ?OPTIONS? ?FILE? Close existing database and reopen FILE
.output ?FILE? Send output to FILE or stdout if FILE is omitted
.parameter CMD ... Manage SQL parameter bindings
.print STRING... Print literal STRING
.progress N Invoke progress handler after every N opcodes
.prompt MAIN CONTINUE Replace the standard prompts
.quit Stop interpreting input stream, exit if primary.
.read FILE Read input from FILE or command output
.recover Recover as much data as possible from corrupt db.
.restore ?DB? FILE Restore content of DB (default "main") from FILE
.save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...)
.scanstats on|off|est Turn sqlite3_stmt_scanstatus() metrics on or off
.schema ?PATTERN? Show the CREATE statements matching PATTERN
.selftest ?OPTIONS? Run tests defined in the SELFTEST table
.separator COL ?ROW? Change the column and row separators
.sha3sum ... Compute a SHA3 hash of database content
.shell CMD ARGS... Run CMD ARGS... in a system shell
.show Show the current values for various settings
.stats ?ARG? Show stats or turn stats on or off
.system CMD ARGS... Run CMD ARGS... in a system shell
.tables ?TABLE? List names of tables matching LIKE pattern TABLE
.testcase NAME Begin redirecting output to 'testcase-out.txt'
.testctrl CMD ... Run various sqlite3_test_control() operations
.timeout MS Try opening locked tables for MS milliseconds
.timer on|off Turn SQL timer on or off
.trace ?OPTIONS? Output each SQL statement as it is run
.version Show source, library and compiler versions
.vfsinfo ?AUX? Information about the top-level VFS
.vfslist List all available VFSes
.vfsname ?AUX? Print the name of the VFS stack
.width NUM1 NUM2 ... Set minimum column widths for columnar output
sqlite> .exit // 退出






审核编辑:刘清

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 存储器
    +关注

    关注

    38

    文章

    7151

    浏览量

    162002
  • 嵌入式系统
    +关注

    关注

    40

    文章

    3431

    浏览量

    128227
  • SQlite
    +关注

    关注

    0

    文章

    78

    浏览量

    15769
  • openwrt系统
    +关注

    关注

    0

    文章

    2

    浏览量

    1525

原文标题:【openwrt】移植sqlite 交叉编译sqlite3

文章出处:【微信号:嵌入式加油站,微信公众号:嵌入式加油站】欢迎添加关注!文章转载请注明出处。

收藏 人收藏

    评论

    相关推荐

    【OK210试用体验】sqlite3移植

    配置的是编译后安装位置,--host配置的是交叉编译工具前缀cd sqlite3mkdir install./configure --prefix=./install --host
    发表于 09-21 16:02

    【创龙AM4379 Cortex-A9试用体验】之移植Python2.7与sqlite3到TL-4379

    ,将sqlite3安装到的目标路径。生成Makefile后,开始交叉编译sqlite3,执行命令:make编译结束后,执行安装命令:make
    发表于 06-29 18:46

    【Intel Edison试用体验】XDK篇:SQLite3安装与体验

    不同的系统包对命名有差异,但是总体还是一样。 可以看出edison的sqlite的包名是sqlite3,故opkg install sqlite3,安装完成后可以在shell下运行sqlite
    发表于 07-25 07:34

    arm 移植 sqlite3 数据库

    libsqlite3.so.0.8.6 libsqlite3.so运行,sqlite3 ,出现SQLite version 3.8.5 2014-06-04 14:06:34等信息,
    发表于 02-21 22:46

    SQLite3在ARM Cortex-A9开发板上的移植

    ***ssf-linux-gnueabi/sysroot/usr/include/ ---->此路径的头文件是虚拟机CROSS_COMPILE的,为以后编译对应的视频应用程序做好准备工作。  拷贝动态库  进入sqlite3
    发表于 03-12 10:57

    SQLite3在ARM Cortex-A9开发板上的移植

    ***ssf-linux-gnueabi/sysroot/usr/include/ ---->此路径的头文件是虚拟机CROSS_COMPILE的,为以后编译对应的视频应用程序做好准备工作。  拷贝动态库  进入sqlite3
    发表于 03-17 17:30

    Linux sqlite3的基本命令操作

    sqlite3一款主要用于嵌入式的轻量级数据库,本文旨在为熟悉sqlite3基本命令提供技术文档。
    发表于 07-16 06:29

    Sqlite3移植和使用-移植到ARM开发板上

    );select * from demo;C代码如下,具体可参照目录下的demo源码交叉编译:arm-linux-gnueabihf-gcc-I /home/ubuntu/sqlite3/install
    发表于 09-18 11:37

    如何将sqlite3移植到ARM开发板上?

    本章节介绍如何将 sqlite3 移植到 ARM 开发板上,以及在开发板上用 C 语言操作 sqlite3,相关的配套资料在网盘资料“iTOP-i.MX6 开发板资料汇总(不含光盘资料)/08_iTOP-i.MX6 开发板 Li
    发表于 04-02 07:23

    深入理解SQLite3sqlite3_exec及回调函数sqlite3

    深入理解SQLite3sqlite3_exec及回调函数sqlite3:深入理解sqlite3_stmt 机制sqlite3:
    发表于 11-04 07:11

    怎样将sqlite3数据库交叉编译移植到嵌入式开发板上去呢

    怎样将sqlite3数据库交叉编译移植到嵌入式开发板上去呢?有哪些操作流程?
    发表于 12-27 07:31

    sqlite3移植所需的线程

    上一篇文章中提供了vfs支持,此处主要是sqlite3移植所需的线程,信号量支持,sqlite3源码在官方下载,需要很大的内存支持,移植基本原理就是实现
    发表于 02-11 06:13

    嵌入式数据库Sqlite移植教程

    嵌入式数据库Sqlite移植教程 sqlite-3.3.6编译安装与交叉编译全过程详细记录
    发表于 03-11 09:57 3618次阅读

    sqlite3在嵌入式Linux上的移植步骤详解

    深入理解SQLite3sqlite3_exec及回调函数sqlite3:深入理解sqlite3_stmt 机制sqlite3:
    发表于 11-01 17:38 4次下载
    <b class='flag-5'>sqlite3</b>在嵌入式Linux上的<b class='flag-5'>移植</b>步骤详解

    单片机裸机移植sqlite3

    上一篇文章中提供了vfs支持,此处主要是sqlite3移植所需的线程,信号量支持,sqlite3源码在官方下载,需要很大的内存支持,移植基本原理就是实现
    发表于 12-08 13:21 7次下载
    单片机裸机<b class='flag-5'>移植</b><b class='flag-5'>sqlite3</b>