Pyrqlite
Python (DB-API 2.0) Client for rqlite, the lightweight, distributed database built on SQLite.
Install / Use
/learn @rqlite/PyrqliteREADME
pyrqlite
.. image:: https://circleci.com/gh/rqlite/pyrqlite.svg?style=svg :target: https://circleci.com/gh/rqlite/pyrqlite
This package contains a pure-Python rqlite client library.
.. contents::
Requirements
-
Python -- one of the following:
- CPython_ >= 2.7 or >= 3.3
-
rqlite Server
Installation
The last stable release is available on github and can be installed with pip::
$ pip install git+https://github.com/rqlite/pyrqlite.git
You can also just clone the repo and install it from source::
$ git clone https://github.com/rqlite/pyrqlite.git
$ cd pyrqlite
$ python setup.py install
Finally (e.g. if pip is not available), a tarball can be downloaded
from GitHub and installed with Setuptools::
$ # X.Y.Z is the desired pyrqlite version (e.g. 2.2.1).
$ curl -L https://github.com/rqlite/pyrqlite/archive/refs/tags/vX.Y.Z.tar.gz | tar xz
$ cd pyrqlite*
$ python setup.py install
$ # The folder pyrqlite* can be safely removed now.
You mean need to run the installation process with root privileges.
Test Suite
To run all the tests, execute the script setup.py::
$ python setup.py test
pytest (https://pytest.org/) and pytest-cov are required to run the test
suite. They can both be installed with pip
Example
The following code creates a connection and executes some statements:
.. code:: python
import pyrqlite.dbapi2 as dbapi2
# Connect to the database
connection = dbapi2.connect(
host='localhost',
port=4001,
)
try:
with connection.cursor() as cursor:
cursor.execute('CREATE TABLE foo (id integer not null primary key, name text)')
cursor.executemany('INSERT INTO foo(name) VALUES(?)', seq_of_parameters=(('a',), ('b',)))
with connection.cursor() as cursor:
# Read a single record with qmark parameter style
sql = "SELECT `id`, `name` FROM `foo` WHERE `name`=?"
cursor.execute(sql, ('a',))
result = cursor.fetchone()
print(result)
# Read a single record with named parameter style
sql = "SELECT `id`, `name` FROM `foo` WHERE `name`=:name"
cursor.execute(sql, {'name': 'b'})
result = cursor.fetchone()
print(result)
finally:
connection.close()
.. code:: python
This example will print:
(1, 'a')
(2, 'b')
Paramstyle
Only qmark and named paramstyles (as defined in PEP 249) are supported.
Limitations
Transactions are not supported.
Resources
DB-API 2.0: http://www.python.org/dev/peps/pep-0249
License
pyrqlite is released under the MIT License. See LICENSE for more information.
Related Skills
feishu-drive
339.3k|
things-mac
339.3kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
339.3kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
yu-ai-agent
2.0k编程导航 2025 年 AI 开发实战新项目,基于 Spring Boot 3 + Java 21 + Spring AI 构建 AI 恋爱大师应用和 ReAct 模式自主规划智能体YuManus,覆盖 AI 大模型接入、Spring AI 核心特性、Prompt 工程和优化、RAG 检索增强、向量数据库、Tool Calling 工具调用、MCP 模型上下文协议、AI Agent 开发(Manas Java 实现)、Cursor AI 工具等核心知识。用一套教程将程序员必知必会的 AI 技术一网打尽,帮你成为 AI 时代企业的香饽饽,给你的简历和求职大幅增加竞争力。
