@@ -397,9 +397,12 @@ Connection Objects
397
397
.. method :: blobopen(table, column, row, /, *, readonly=False, name="main")
398
398
399
399
Open a :class: `Blob ` handle to the :abbr: `BLOB ( Binary Large OBject ) `
400
- located in row *row *, column *column *, table *table * of database *name *.
400
+ located in table name *table *, column name *column *, and row index *row *
401
+ of database *name *.
401
402
When *readonly * is :const: `True ` the blob is opened without write
402
403
permissions.
404
+ Trying to open a blob in a ``WITHOUT ROWID `` table will raise
405
+ :exc: `OperationalError `.
403
406
404
407
.. note ::
405
408
@@ -1044,6 +1047,57 @@ Now we plug :class:`Row` in::
1044
1047
35.14
1045
1048
1046
1049
1050
+ Blob Objects
1051
+ ------------
1052
+
1053
+ .. versionadded :: 3.11
1054
+
1055
+ .. class :: Blob
1056
+
1057
+ A :class: `Blob ` instance is a :term: `file-like object ` that can read and write
1058
+ data in an SQLite :abbr: `BLOB ( Binary Large OBject ) `. Call ``len(blob) `` to
1059
+ get the size (number of bytes) of the blob.
1060
+
1061
+ Use the :class: `Blob ` as a :term: `context manager ` to ensure that the blob
1062
+ handle is closed after use.
1063
+
1064
+ .. literalinclude :: ../includes/sqlite3/blob.py
1065
+
1066
+ .. method :: close()
1067
+
1068
+ Close the blob.
1069
+
1070
+ The blob will be unusable from this point onward. An
1071
+ :class: `~sqlite3.Error ` (or subclass) exception will be raised if any
1072
+ further operation is attempted with the blob.
1073
+
1074
+ .. method :: read(length=-1, /)
1075
+
1076
+ Read *length * bytes of data from the blob at the current offset position.
1077
+ If the end of the blob is reached, the data up to
1078
+ :abbr: `EOF ( End of File ) ` will be returned. When *length * is not
1079
+ specified, or is negative, :meth: `~Blob.read ` will read until the end of
1080
+ the blob.
1081
+
1082
+ .. method :: write(data, /)
1083
+
1084
+ Write *data * to the blob at the current offset. This function cannot
1085
+ change the blob length. Writing beyond the end of the blob will raise
1086
+ :exc: `ValueError `.
1087
+
1088
+ .. method :: tell()
1089
+
1090
+ Return the current access position of the blob.
1091
+
1092
+ .. method :: seek(offset, origin=os.SEEK_SET, /)
1093
+
1094
+ Set the current access position of the blob to *offset *. The *origin *
1095
+ argument defaults to :data: `os.SEEK_SET ` (absolute blob positioning).
1096
+ Other values for *origin * are :data: `os.SEEK_CUR ` (seek relative to the
1097
+ current position) and :data: `os.SEEK_END ` (seek relative to the blob’s
1098
+ end).
1099
+
1100
+
1047
1101
.. _sqlite3-exceptions :
1048
1102
1049
1103
Exceptions
@@ -1104,57 +1158,6 @@ Exceptions
1104
1158
1105
1159
.. _sqlite3-blob-objects :
1106
1160
1107
- Blob Objects
1108
- ------------
1109
-
1110
- .. versionadded :: 3.11
1111
-
1112
- .. class :: Blob
1113
-
1114
- A :class: `Blob ` instance is a :term: `file-like object ` that can read and write
1115
- data in an SQLite :abbr: `BLOB ( Binary Large OBject ) `. Call ``len(blob) `` to
1116
- get the size (number of bytes) of the blob.
1117
-
1118
- Use the :class: `Blob ` as a :term: `context manager ` to ensure that the blob
1119
- handle is closed after use.
1120
-
1121
- .. literalinclude :: ../includes/sqlite3/blob.py
1122
-
1123
- .. method :: close()
1124
-
1125
- Close the blob.
1126
-
1127
- The blob will be unusable from this point onward. An
1128
- :class: `~sqlite3.Error ` (or subclass) exception will be raised if any
1129
- further operation is attempted with the blob.
1130
-
1131
- .. method :: read(length=-1, /)
1132
-
1133
- Read *length * bytes of data from the blob at the current offset position.
1134
- If the end of the blob is reached, the data up to
1135
- :abbr: `EOF ( End of File ) ` will be returned. When *length * is not
1136
- specified, or is negative, :meth: `~Blob.read ` will read until the end of
1137
- the blob.
1138
-
1139
- .. method :: write(data, /)
1140
-
1141
- Write *data * to the blob at the current offset. This function cannot
1142
- change the blob length. Writing beyond the end of the blob will raise
1143
- :exc: `ValueError `.
1144
-
1145
- .. method :: tell()
1146
-
1147
- Return the current access position of the blob.
1148
-
1149
- .. method :: seek(offset, origin=os.SEEK_SET, /)
1150
-
1151
- Set the current access position of the blob to *offset *. The *origin *
1152
- argument defaults to :data: `os.SEEK_SET ` (absolute blob positioning).
1153
- Other values for *origin * are :data: `os.SEEK_CUR ` (seek relative to the
1154
- current position) and :data: `os.SEEK_END ` (seek relative to the blob’s
1155
- end).
1156
-
1157
-
1158
1161
.. _sqlite3-types :
1159
1162
1160
1163
SQLite and Python types
0 commit comments