<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query(self, q, data=None, union=True, limit=None):
 """ Query your database with a raw string. Parameters q: str Query string to execute data: list, dict Optional argument for handlebars-queries. Data will be passed to the template and rendered using handlebars. union: bool Whether or not "UNION ALL" handlebars templates. This will return any handlebars queries as a single data frame. limit: int Number of records to return Examples -------- db.query("select * from Track").head(2) TrackId Name AlbumId MediaTypeId \\\r 0 1 For Those About To Rock (We Salute You) 1 1 1 2 Balls to the Wall 2 2 <BLANKLINE> GenreId Composer Milliseconds Bytes \\\r 0 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 1 1 None 342562 5510424 <BLANKLINE> UnitPrice 0 0.99 1 0.99 db.query("select * from Track", limit=10) TrackId Name AlbumId MediaTypeId \ 0 1 For Those About To Rock (We Salute You) 1 1 1 2 Balls to the Wall 2 2 2 3 Fast As a Shark 3 2 3 4 Restless and Wild 3 2 4 5 Princess of the Dawn 3 2 5 6 Put The Finger On You 1 1 6 7 Let's Get It Up 1 1 7 8 Inject The Venom 1 1 8 9 Snowballed 1 1 9 10 Evil Walks 1 1 GenreId Composer Milliseconds \ 0 1 Angus Young, Malcolm Young, Brian Johnson 343719 1 1 None 342562 4 1 Deaffy & R.A. Smith-Diesel 375418 5 1 Angus Young, Malcolm Young, Brian Johnson 205662 6 1 Angus Young, Malcolm Young, Brian Johnson 233926 7 1 Angus Young, Malcolm Young, Brian Johnson 210834 8 1 Angus Young, Malcolm Young, Brian Johnson 203102 9 1 Angus Young, Malcolm Young, Brian Johnson 263497 Bytes UnitPrice 0 11170334 0.99 1 5510424 0.99 2 3990994 0.99 3 4331779 0.99 4 6290521 0.99 5 6713451 0.99 6 7636561 0.99 7 6852860 0.99 8 6599424 0.99 9 8611245 0.99 3503 db.query(q, limit=10) Title \ 0 For Those About To Rock We Salute You 1 Balls to the Wall 2 Restless and Wild 3 Restless and Wild 4 Restless and Wild 5 For Those About To Rock We Salute You 6 For Those About To Rock We Salute You 7 For Those About To Rock We Salute You 8 For Those About To Rock We Salute You 9 For Those About To Rock We Salute You Name UnitPrice 0 For Those About To Rock (We Salute You) 0.99 1 Balls to the Wall 0.99 2 Fast As a Shark 0.99 3 Restless and Wild 0.99 4 Princess of the Dawn 0.99 5 Put The Finger On You 0.99 6 Let's Get It Up 0.99 7 Inject The Venom 0.99 8 Snowballed 0.99 9 Evil Walks 0.99 db.query(q, data=data) table_name cnt 0 Album 347 1 Artist 275 2 Track 3503 347 db.query(q, data=data, union=False) AlbumId Title ArtistId 0 1 For Those About To Rock We Salute You 1 1 2 Balls to the Wall 2 2 3 Restless and Wild 2 3 4 Let There Be Rock 1 4 5 Big Ones 3 """

        if data:
            q = self._apply_handlebars(q, data, union)
        if limit:
            q = self._assign_limit(q, limit)
        return pd.read_sql(q, self.con)