I am having hard time figuring out how MRJob works. I am trying to make an sql query and yield its rows, and in the documentation there is no such thing explained in details.
My code so far:
# To be able to give db file as option.
def configure_options(self):
super(MyClassName, self).configure_options()
self.add_file_option('--database')
def mapper_init(self):
# Making sqlite3 database available to mapper.
self.sqlite_conn = sqlite3.connect(self.options.database)
self.command= '''
SELECT id
FROM names
'''
def mapper(self,_,val):
yield self.sqlite_conn.execute(self.command), 1
And in console I write
python myfile.py text.txt --database=mydb.db
Where text.txt is an empty dummy file so the script will not ask for std input.
I am expecting the output to be:
id1, 1
id2, 1
But now there is no output. What am I missing?