Repository navigation
Extending Connectors
A connector needs a dialect name and one
executemethod; the rest is optional. Wrap any PEP 249 connection withDBAPIConnector, or write a small class for a warehouse with its own client. Declare your parameter style and map failures to the standard codes.
class MyConnector:
dialect = "postgres" # a profile name
paramstyle = "pyformat" # how your driver wants parameters
def execute(self, sql, params, *, timeout_s):
rows = my_driver.run(sql, params, timeout=timeout_s)
return QueryResult(rows=[dict(r) for r in rows], bytes_processed=None)QueryResult comes from factlang.connectors. Rows must be plain dicts keyed by column name; the wire-format metric aliases come back exactly as the SQL names them.
-
Async: add
aexecuteto serveChecker.acheckandameasure. -
Dry run: a method that prices a query without running it enables the
max_bytesguard andChecker.estimate. Without it, estimates reportunknown. - bytes_processed: fill it in when your warehouse reports it; it appears in evidence.
Raise errors that carry FL700 for a failed query and FL702 for a timeout; the engine turns them into error outcomes. Never swallow a failure into empty rows: an empty result would read as no_data.
If your host already runs SQL, give FactLang a function: fl.CallableConnector(fn, "snowflake").
Run a seeded tiny table through fl.check for one PASS, one FAIL and one NO_DATA claim. Also test a timeout and a rejected query, and that run_metadata works through your connector.
FactLang
Using it
Components
Extending
Help