Skip to content

Commit

Permalink
support headers for rbql-sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
mechatroner committed Jun 10, 2021
1 parent 6592862 commit 5c7f5d0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rbql/rbql_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ 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

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):
Expand Down
1 change: 1 addition & 0 deletions test/sqlite_files/expected_result_1.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions test/sqlite_files/expected_result_2.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions test/sqlite_files/expected_result_3.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SurveyID,Description
2014,Year 2014 survey
2016,Year 2016 survey
2017,Year 2017 survey
Expand Down

0 comments on commit 5c7f5d0

Please sign in to comment.