How to use the jardin.database.drivers.sf.Lexicon function in jardin

To help you get started, we’ve selected a few jardin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instacart / jardin / tests / test_query.py View on Github external
def test_snowflake_lexicon(self):
        from jardin.database.drivers.sf import Lexicon
        sql, params = Lexicon.standardize_interpolators(
            'SELECT * FROM users WHERE a = %(abc)s AND b = %(def)s',
            {'def': 2, 'abc': 1}
            )
        self.assertEqual(
            'SELECT * FROM users WHERE a = %s AND b = %s',
            sql
            )
        self.assertEqual([1, 2], params)
github instacart / jardin / jardin / database / drivers / sf.py View on Github external
def standardize_interpolators(sql, params):
        sql, params = super(Lexicon, Lexicon).standardize_interpolators(sql, params)
        param_names = re.findall(r'\%\((\w+)\)s', sql)
        if len(param_names):
            sql = re.sub(r'\%\(\w+\)s', '%s', sql)
            if isinstance(params, dict):
                params = list(map(lambda x: params[x], param_names))
        return sql, params