torch_geometric.data.SQLiteDatabase
- class SQLiteDatabase(path: str, name: str, schema: ~typing.Union[~typing.Any, ~typing.Dict[str, ~typing.Any], ~typing.Tuple[~typing.Any], ~typing.List[~typing.Any]] = <class 'object'>)[source]
Bases:
Database
An index-based key/value database based on
sqlite3
.Note
This database implementation requires the
sqlite3
package.- Parameters:
path (str) – The path to where the database should be saved.
name (str) – The name of the table to save the data to.
schema (Any or Tuple[Any] or Dict[str, Any], optional) – The schema of the input data. Can take
int
,float
,str
,object
, or a dictionary withdtype
andsize
keys (for specifying tensor data) as input, and can be nested as a tuple or dictionary. Specifying the schema will improve efficiency, since by default the database will use python pickling for serializing and deserializing. (default:object
)
- connect() None [source]
Connects to the database. Databases will automatically connect on instantiation.
- insert(index: int, data: Any) None [source]
Inserts data at the specified index.
- Parameters:
index (int) – The index at which to insert.
data (Any) – The object to insert.
- get(index: int) Any [source]
Gets data from the specified index.
- Parameters:
index (int) – The index to query.
- multi_get(indices: Union[Sequence[int], Tensor, slice, range], batch_size: Optional[int] = None) List[Any] [source]
Gets a chunk of data from the specified indices.
- Parameters:
indices (List[int] or torch.Tensor or range) – The indices to query.
batch_size (int, optional) – If specified, will request the data from the database in batches of size
batch_size
. (default:None
)
- multi_insert(indices: Union[Sequence[int], Tensor, slice, range], data_list: Sequence[Any], batch_size: Optional[int] = None, log: bool = False) None
Inserts a chunk of data at the specified indices.
- Parameters:
indices (List[int] or torch.Tensor or range) – The indices at which to insert.
data_list (List[Any]) – The objects to insert.
batch_size (int, optional) – If specified, will insert the data to the database in batches of size
batch_size
. (default:None
)log (bool, optional) – If set to
True
, will log progress to the console. (default:False
)