Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Raw numpy scalar values get silently stored as corrupted BLOBs instead of being converted

Open Beginner friendly
#876 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python, sqlite
Domain
cli, databases, tooling

Research direction

Look at the jsonify_if_needed() function in db.py to see how values are converted before insertion. The issue is that numpy scalar types like np.int64 are not recognized and get stored as binary. Add handling for numpy scalar types by checking for np.generic or using .item() to extract the Python native value. Test by running the provided repro script and verifying the output is {'col': 5}.

Written by the indexing model from the issue text.

Description

While working on #872, I found that passing raw numpy scalar values (e.g. np.int64(5), not run through pandas or .item()) directly into insert_all() doesn't get converted to a normal SQLite INTEGER/REAL — instead it silently stores garbage binary data as a BLOB. Repro:

python
import sqlite_utils, numpy as np
db = sqlite_utils.Database(memory=True)
db["t"].insert_all([{"col": np.int64(5)}])
print(list(db["t"].rows))

{'col': b'\x05\x00\x00\x00\x00\x00\x00\x00'} instead of {'col': 5}

This likely affects anyone using numpy arrays directly without pandas. Might be worth adding numpy-scalar handling to jsonify_if_needed() in db.py.

Dominant language
Python
Stars
2.2k
Forks
172
Avg merge
9m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from simonw/sqlite-utils

All issues in simonw/sqlite-utils

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.