- class dataikuapi.dss.sqlquery.DSSSQLQuery(client, query, connection, database, dataset_full_name, pre_queries, post_queries, type, extra_conf, script_steps, script_input_schema, script_output_schema, script_report_location, read_timestamp_without_timezone_as_string, read_date_as_string, project_key)#
A connection to a database or database-like on which queries can be run through DSS.
Do not create this class directly, instead use
# run some query on a connection query = client.sql_query('select * from "public"."SOME_TABLE"', connection='some_postgres_connection') n = 0 for row in query.iter_rows(): n += 1 if n < 10: print("row %s : %s" % (n, row)) query.verify() print("Returned %s rows" % n)
Get the query’s result set’s schema.
The schema made of DSS column types, and built from mapping database types to DSS types. The actual type in the database can be found in the originalType field (originalSQLType in BigQuery)
a schema, as a dict with a columns array, in which each element is a column, itself as a dict of
name : the column name
type : the column type (smallint, int, bigint, float, double, boolean, date, string)
length : the string length
comment : the column name
originalType : type of the column in the database
- Return type:
Get an iterator on the query’s results.
Verify that reading results completed successfully.
When using the
iter_rows()method, and the iterator stops returning rows, there is no way to tell whether there are no more rows because the query didn’t return more rows, or because an error in the query, or in the fetching of its results, happened. You should thus call
verify()after the iterator is done, because it will raise an Expcetion if an error happened.