{"id":15619303,"url":"https://github.com/andy-y-li/pi-db","last_synced_at":"2026-05-11T03:07:37.497Z","repository":{"id":86473944,"uuid":"257846748","full_name":"andy-y-li/pi-db","owner":"andy-y-li","description":"povide access sqlite on pi","archived":false,"fork":false,"pushed_at":"2020-04-22T09:00:18.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T16:18:35.552Z","etag":null,"topics":["gin","go-server","golang","sqlite"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andy-y-li.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-22T08:58:29.000Z","updated_at":"2020-04-28T06:56:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ac2d120-ab76-4f31-a9dd-d9e2444c04bd","html_url":"https://github.com/andy-y-li/pi-db","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-y-li%2Fpi-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-y-li%2Fpi-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-y-li%2Fpi-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-y-li%2Fpi-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andy-y-li","download_url":"https://codeload.github.com/andy-y-li/pi-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246202782,"owners_count":20740028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gin","go-server","golang","sqlite"],"created_at":"2024-10-03T08:04:48.049Z","updated_at":"2026-05-11T03:07:32.473Z","avatar_url":"https://github.com/andy-y-li.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pi-db\n\n  本文使用go语言的server框架[gin](https://github.com/gin-gonic/gin) 实现在树莓派上提供远程访问数据库(sqlite)服务.\n\n+ ***项目结构***\n\n```\n.\n├── README.md\n├── apis\n│   └── cpuInfo.go\n├── database\n│   └── cpu.db\n├── main.go\n├── models\n│   ├── cpu.go\n│   └── sqlite.go\n└── routers\n    └── router.go\n```\n\n 在routers中设置好相关的路由(目前只有GET)，由apis中来实现，它经由models来实现。\n\n+ ***编译与安装***\n\n1. 在电脑平台上先安装 gin:\n\n```\n$ go get -u github.com/gin-gonic/gin\n```\n\n2. ***编译***\n\n```\n$ go build\n```\n\n3. ***交叉编译树莓派版本***\n\n​      由于用sqlite 数据库，需要用cgo来编译sqlite对应的版本，需要安装gcc的交叉编译器[arm-linux-gcc](https://github.com/downloads/UnhandledException/ARMx/ARMx-2009q3-67.tar.bz2)，\n\n​        把ARMx-2009q3-67.tar.bz2下载后解压放在/usr/local/arm-gcc下：\n\n```\n/usr/local/arm-gcc\n├── arm-none-linux-gnueabi\n├── bin\n├── lib\n├── libexec\n└── share\n```\n\nb. 再声明环境变量：\n\n```\n$ export PATH=\"/usr/local/arm-gcc/bin:$PATH\"\n```\n\nc. 检验一下是否安装成功：\n\n```\n$ which arm-none-linux-gnueabi-gcc\n/usr/local/arm-gcc/bin/arm-none-linux-gnueabi-gcc\n```\n\nd. 编译树莓版本：\n\n```\n$ CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-none-linux-gnueabi-gcc go build\n```\n\n+ ***运行***\n\n   把生成的目标文件pi-db和文件夹database一起传到树莓派上，启动程序：\n\n```\n$ ./pi-db\n```\n\n\n\n+ ***访问方法***\n\n```\ncurl -i http://localhost:8080/api/cpu/T\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy-y-li%2Fpi-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy-y-li%2Fpi-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy-y-li%2Fpi-db/lists"}