Skip to main content

sqlite-rw

为sqlite提供读写分离能力,提高并发度。

解决什么问题?

sqlite是一个很好用的嵌入式数据库,但是由于sqlite采用了库级别的文件锁,所以并发能力不强,当存在慢SQL,比如在大表上select count(*) from large_table的时候,会导致其他任务无法写入。

sqlite-rw就是为了解决这个问题的,思路如下

  • 采用读写分离的存储模式,每次写入会持久化写库,并且记录日志到binlog表,然后异步写入读库。
  • 读取的时候可以选择从读库或者写库读取,默认从读库读取。

提高并发度的原理

  • sqlite本身读取是支持并发的,但是写入是不能和读取并发的。所以读库本身是支持并发读取的,同步的写操作是通过id主键写入的,耗时会比较短,基本上不会阻塞读操作。
  • 由于是读写分离的,在读库存在慢SQL的情况下,写库也能够正常工作,在读库慢SQL执行完成之后,系统会把写库的数据同步到读库中,使两者保持一致。

使用限制和影响

  • 存储量相比于单独的sqlite会翻倍
  • 写入性能会有所下降,待详细的基准测试
  • 依赖web.py的db接口进行操作

Metadata

Release files for sqlite-rw 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlite-rw 0.0.2
File Size Uploaded Provenance
sqlite-rw-0.0.2.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlite-rw 0.0.2
File Interpreter ABI Platform
sqlite_rw-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / sqlite-rw-0.0.2.tar.gz

Download URL sqlite-rw-0.0.2.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7fb4fae1380e3f3734be2fb5c411ffaee0a0841746c4a78e6dbc64a0853494aa
BLAKE2b-256 checksum
How to use checksums
616b494e34f7f3e554ebecce7e625cb0af4521ae8b3d7ad97ea2d7cc1ba55727
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / sqlite_rw-0.0.2-py3-none-any.whl

Download URL sqlite_rw-0.0.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98fe5db5f65c6dcaad0df305820b9b4d7e11923cbe4611b0de53b7648970ff25
BLAKE2b-256 checksum
How to use checksums
cf5738e422d1c542985957f353d06889d9b867f025b54de51b2dcaea0f4116f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for sqlite-rw 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page