RecSQL
RecSQL is a hack that allows one to load table-like data records into an in-memory sqlite database for quick and dirty analysis via SQL. The SQLarray class has additional SQL functions such as sqrt or histogram defined. SQL tables can always be returned as numpy record arrays so that data can be easily handled in other packages such as numpy or plotted via matplotlib. Selections produce new SQLarray objects.
Install / Use
/learn @orbeckst/RecSQLREADME
========= README
|docs|
RecSQL's basic idea is to treat numpy record arrays like SQL tables. What it does, in fact, is to represent the arrays as real SQL tables (using SQLite) and provide convenience functions to return recarrays on demand.
This works ok for small tables but less so if you want to access gigabytes of data as recarrays. It's a hack.
Documentation can be found at http://recsql.readthedocs.org/
Source code is available from https://github.com/orbeckst/RecSQL under
the GNU General Public License, version 3_ (see also the file
LICENSE in the distribution).
.. _GNU General Public License, version 3:
http://www.gnu.org/licenses/gpl-3.0.en.html
Example
from recsql import SQLarray import numpy a = numpy.rec.fromrecords(numpy.arange(100).reshape(25,4), names='a,b,c,d') Q = SQLarray('my_name', a) print repr(Q.recarray) rec.array([(0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11), (12, 13, 14, 15), (16, 17, 18, 19), (20, 21, 22, 23), (24, 25, 26, 27), (28, 29, 30, 31), (32, 33, 34, 35), (36, 37, 38, 39), (40, 41, 42, 43), (44, 45, 46, 47), (48, 49, 50, 51), (52, 53, 54, 55), (56, 57, 58, 59), (60, 61, 62, 63), (64, 65, 66, 67), (68, 69, 70, 71), (72, 73, 74, 75), (76, 77, 78, 79), (80, 81, 82, 83), (84, 85, 86, 87), (88, 89, 90, 91), (92, 93, 94, 95), (96, 97, 98, 99)], dtype=[('a', '<i4'), ('b', '<i4'), ('c', '<i4'), ('d', '<i4')]) Q.SELECT('*', 'WHERE a < 10 AND b > 5') rec.array([(8, 9, 10, 11)], dtype=[('a', '<i4'), ('b', '<i4'), ('c', '<i4'), ('d', '<i4')])
creating new SQLarrays:
R = Q.selection('a < 20 AND b > 5') print R <recsql.sqlarray.SQLarray object at 0x...>
Availability
The latest version of the package is available on GitHub https://github.com/orbeckst/RecSQL
RecSQL is also listed on PyPi http://pypi.python.org/pypi/RecSQL and can thus be installed with ::
pip install RecSQL
See :doc:INSTALL for further installation instructions.
A git repository of the package is hosted at http://github.com/orbeckst/RecSQL .
Getting Involved
Please submit problems, questions and questions through the issue tracker_. Pull requests are also very welcome.
.. _issue tracker: https://github.com/orbeckst/RecSQL/issues
.. |docs| image:: http://readthedocs.org/projects/recsql/badge/?version=latest :target: http://recsql.readthedocs.org/en/latest/?badge=latest :alt: Documentation Status
Related Skills
feishu-drive
343.1k|
things-mac
343.1kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
343.1kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
codebase-memory-mcp
1.1kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 66 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
