On this page
sqlite3.Binary
Prev: sqlite3.adapt | Up: sqlite3 | Next: sqlite3.Blob
Rel: sqlite3.adapt, sqlite3.Blob, sqlite3.complete_statement, sqlite3.connect
Ref: docs.python.org — sqlite3.Binary
Tags: #public #python3 #stdlib #sqlite3
Import
import sqlite3
from sqlite3 import Binary
Signature & Overview
sqlite3.Binary(object)
Create a new memoryview object which references the given object.
Methods & Attributes
Binary.cast(...)— Cast a memoryview to a new format or shape.Binary.count(self, value, /)— Count the number of occurrences of a value.Binary.hex(...)— Return the data in the buffer as a str of hexadecimal numbers.Binary.index(self, value, start=0, stop=9223372036854775807, /)— Return the index of the first occurrence of a value.Binary.release(self, /)— Release the underlying buffer exposed by the memoryview object.Binary.tobytes(self, /, order='C')— Return the data in the buffer as a byte string.Binary.tolist(self, /)— Return the data in the buffer as a list of elements.Binary.toreadonly(self, /)— Return a readonly version of the memoryview.
Usage
import sqlite3
val = sqlite3.Binary(b"\x00\x01\x02")
assert bytes(val) == b"\x00\x01\x02"
Gotchas
- DB-API 2.0 compatibility alias for
memoryview: In modernsqlite3, you can bind plainbytesdirectly to BLOB columns without wrapping inBinary().
REPL Inspect
from sqlite3 import Binary
help(Binary)
Linked from
- tuts/python3/stdlib_module/sqlite3
- tuts/python3/stdlib_module/sqlite3/adapt
- tuts/python3/stdlib_module/sqlite3/Blob
- tuts/python3/stdlib_module/sqlite3/complete_statement
- tuts/python3/stdlib_module/sqlite3/connect
- tuts/python3/stdlib_module/sqlite3/Connection
- tuts/python3/stdlib_module/sqlite3/Cursor
- tuts/python3/stdlib_module/sqlite3/DatabaseError
- tuts/python3/stdlib_module/sqlite3/DataError
- tuts/python3/stdlib_module/sqlite3/Date
- tuts/python3/stdlib_module/sqlite3/DateFromTicks
- tuts/python3/stdlib_module/sqlite3/enable_callback_tracebacks
- tuts/python3/stdlib_module/sqlite3/Error
- tuts/python3/stdlib_module/sqlite3/IntegrityError
- tuts/python3/stdlib_module/sqlite3/InterfaceError
- tuts/python3/stdlib_module/sqlite3/InternalError
- tuts/python3/stdlib_module/sqlite3/NotSupportedError
- tuts/python3/stdlib_module/sqlite3/OperationalError
- tuts/python3/stdlib_module/sqlite3/PrepareProtocol
- tuts/python3/stdlib_module/sqlite3/ProgrammingError
- tuts/python3/stdlib_module/sqlite3/register_adapter
- tuts/python3/stdlib_module/sqlite3/register_converter
- tuts/python3/stdlib_module/sqlite3/Row
- tuts/python3/stdlib_module/sqlite3/Time
- tuts/python3/stdlib_module/sqlite3/TimeFromTicks
- tuts/python3/stdlib_module/sqlite3/Timestamp
- tuts/python3/stdlib_module/sqlite3/TimestampFromTicks
- tuts/python3/stdlib_module/sqlite3/Warning
Related notes
- tuts/python3/stdlib_module/sqlite3 Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/adapt Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Blob Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/complete_statement Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/connect Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Connection links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Cursor links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/DatabaseError links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/DataError links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Date links to this page; shared tags: #stdlib