ListDataSource
The ListDataSource works with Python lists of dictionaries. It is useful for small datasets, testing, demos, or when working with preloaded data.
Basic Usage
from ckanext.tables.shared import ListDataSource
# Sample data
users_data = [
{"id": 1, "name": "alice", "email": "alice@example.com", "age": 30},
{"id": 2, "name": "bob", "email": "bob@example.com", "age": 25},
{"id": 3, "name": "charlie", "email": "charlie@example.com", "age": 35},
]
data_source = ListDataSource(users_data)
Definition
A data source that uses a list of dictionaries as the data source.
This is useful for testing and demo purposes, when you already have data on your hand.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The list of dictionaries to use as the data source
TYPE:
|
Source code in ckanext/tables/data_sources.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
Best Practices
- Suitable for small amout of data
- Consider caching expensive data preparation