From 5c7f5d078ad1132d05bd2f7e9b05ebdef3d69396 Mon Sep 17 00:00:00 2001 From: mechatroner Date: Wed, 9 Jun 2021 21:43:39 -0400 Subject: [PATCH] support headers for rbql-sqlite --- rbql/rbql_sqlite.py | 6 +++--- test/sqlite_files/expected_result_1.csv | 1 + test/sqlite_files/expected_result_2.csv | 1 + test/sqlite_files/expected_result_3.csv | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rbql/rbql_sqlite.py b/rbql/rbql_sqlite.py index e8ac26f..48da9d3 100644 --- a/rbql/rbql_sqlite.py +++ b/rbql/rbql_sqlite.py @@ -34,7 +34,7 @@ def __init__(self, db_connection, table_name, variable_prefix='a'): raise rbql_engine.RbqlIOHandlingError('no such table "{}"'.format(table_name)) raise - def get_column_names(self): + def get_header(self): column_names = [description[0] for description in self.cursor.description] return column_names @@ -42,8 +42,8 @@ def get_variables_map(self, query_text): variable_map = dict() rbql_engine.parse_basic_variables(query_text, self.variable_prefix, variable_map) rbql_engine.parse_array_variables(query_text, self.variable_prefix, variable_map) - rbql_engine.parse_dictionary_variables(query_text, self.variable_prefix, self.get_column_names(), variable_map) - rbql_engine.parse_attribute_variables(query_text, self.variable_prefix, self.get_column_names(), 'table column names', variable_map) + rbql_engine.parse_dictionary_variables(query_text, self.variable_prefix, self.get_header(), variable_map) + rbql_engine.parse_attribute_variables(query_text, self.variable_prefix, self.get_header(), 'table column names', variable_map) return variable_map def get_record(self): diff --git a/test/sqlite_files/expected_result_1.csv b/test/sqlite_files/expected_result_1.csv index 0d5d17f..bae79ae 100644 --- a/test/sqlite_files/expected_result_1.csv +++ b/test/sqlite_files/expected_result_1.csv @@ -1,3 +1,4 @@ +questiontext,questionid,col3,col4 What is your age?,1,10,17 What is your gender?,2,20,20 How many employees does your company or organization have?,8,80,58 diff --git a/test/sqlite_files/expected_result_2.csv b/test/sqlite_files/expected_result_2.csv index 1f97728..8cb9bf8 100644 --- a/test/sqlite_files/expected_result_2.csv +++ b/test/sqlite_files/expected_result_2.csv @@ -1,3 +1,4 @@ +UserID,questiontext,AnswerText 10,What is your age?,23 12,What is your age?,29 4,What is your age?,31 diff --git a/test/sqlite_files/expected_result_3.csv b/test/sqlite_files/expected_result_3.csv index 5d08c72..4505271 100644 --- a/test/sqlite_files/expected_result_3.csv +++ b/test/sqlite_files/expected_result_3.csv @@ -1,3 +1,4 @@ +SurveyID,Description 2014,Year 2014 survey 2016,Year 2016 survey 2017,Year 2017 survey