SqlDataFrame¶
Lazy SQL-backed frames (install pydantable[sql]). See SQL engine.
pydantable.sql_dataframe
¶
SQL-backed lazy :class:~pydantable.dataframe.DataFrame (SQLAlchemy 2.x).
Install the optional extra: pip install "pydantable[sql]" (includes moltres-core
and eager SQLModel I/O). Lazy execution is implied by SqlDataFrame /
SqlDataFrameModel. This path needs a SQLAlchemy-oriented engine configuration
object from the same optional stack (see the Lazy SQL DataFrame guide).
sql_engine_from_config builds the execution engine pydantable uses for
SqlDataFrame / SqlDataFrameModel from that configuration.
SqlDataFrame
¶
Bases: DataFrame
Typed dataframe using the optional lazy-SQL execution engine.
Pass sql_config= (engine configuration from the lazy-SQL stack), or
sql_engine= if you already constructed that engine, or engine= for any
compatible :class:~pydantable.engine.ExecutionEngine.
Source code in python/pydantable/sql_dataframe.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 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 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
from_sql
classmethod
¶
Lazy frame from an arbitrary SQLAlchemy selectable.
This is the typed-safe escape hatch for cases where you already have a
SQLAlchemy query/subquery. The selectable must expose .c with column
names that cover the schema fields.
Source code in python/pydantable/sql_dataframe.py
where
¶
Push down a SQLAlchemy WHERE clause to the lazy-SQL root.
Source code in python/pydantable/sql_dataframe.py
from_sql_table
classmethod
¶
Lazy frame from a SQLAlchemy Table / FromClause (no fetch yet).
table must expose columns whose names match the schema model fields.
Materialization runs SELECT via the lazy-SQL engine when you call
to_dict(), collect(), head(), etc.
SQLite :memory:: each new connection pool may be a separate empty
in-memory DB. Create DDL and pass the same sql_engine= (from
:func:sql_engine_from_config) you use for the frame, or use a file
URL (sqlite:///path/to.db) so distinct pools still see one database file.
Use SqlDataFrame[YourSchema].from_sql_table(...).
Source code in python/pydantable/sql_dataframe.py
SqlDataFrameModel
¶
Bases: DataFrameModel
DataFrameModel bound to the optional lazy-SQL execution engine.
Source code in python/pydantable/sql_dataframe.py
read_sql_table
classmethod
¶
Lazy read from a SQLAlchemy table — same engine rules as the constructor.
Source code in python/pydantable/sql_dataframe.py
sql_engine_from_config
¶
Build the lazy-SQL execution engine from sql_config.
sql_config must be an EngineConfig instance from the optional lazy-SQL
dependency (same extra as SqlDataFrame).