Skip to content

feat(python): add __repr__ and __bool__ to SqlmathDb#6

Merged
kaizhu256 merged 2 commits into
sqlmath:betafrom
ababber:feature/repr-bool
May 1, 2026
Merged

feat(python): add __repr__ and __bool__ to SqlmathDb#6
kaizhu256 merged 2 commits into
sqlmath:betafrom
ababber:feature/repr-bool

Conversation

@ababber
Copy link
Copy Markdown
Contributor

@ababber ababber commented Apr 24, 2026

Summary

Adds __repr__ and __bool__ methods to SqlmathDb for better debugging experience.

Before

>>> db = db_open(':memory:')
>>> db
<sqlmath.SqlmathDb object at 0x...>
>>> bool(db)  # TypeError or always True

After

>>> db = db_open(':memory:')
>>> db
SqlmathDb(':memory:', open)
>>> bool(db)
True
>>> db_close(db)
>>> db
SqlmathDb(':memory:', closed)
>>> bool(db)
False

Use case

if db:
    db_exec(db=db, sql="SELECT 1")

No breaking changes.

Made with Cursor

Improves debugging experience:

    >>> db = db_open(':memory:')
    >>> db
    SqlmathDb(':memory:', open)
    >>> bool(db)
    True
    >>> db_close(db)
    >>> db
    SqlmathDb(':memory:', closed)
    >>> bool(db)
    False

No breaking changes.

Made-with: Cursor
@kaizhu256
Copy link
Copy Markdown
Contributor

  • can you update CHANGELOG.md with a one-line description of changes? e.g.:
 # v2026.4.1-beta
+- sqlmath-python - Add __repr__ and __bool__ methods to SqlmathDb for better debugging experience.
 - sqlmath - Removue under-used custom-files sqlmath_custom.c, sqlmath_custom.mjs.
  • otherwise, LGTM : )

Per maintainer request in PR sqlmath#6.

Made-with: Cursor
@kaizhu256 kaizhu256 merged commit 0d98b1f into sqlmath:beta May 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants