How to use jardin - 10 common examples

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 / __init__.py View on Github external
def wrapper(*args, **kwargs):
            if DatabaseConnections.connection('jardin_test').db_config.scheme in schemes:
                return func(*args, **kwargs)
github instacart / jardin / tests / __init__.py View on Github external
def __init__(self, model=None, create_table=True, extra_tables=[]):
        self._model = model
        self.tables = extra_tables
        if self._model:
            self._model.clear_caches()
        self._connection = DatabaseConnections.connection('jardin_test')
        self.create_table = create_table
github instacart / jardin / tests / test_query.py View on Github external
def test_query_filename_relative(self):
        User.insert(values={'name': 'jardin'})
        df = jardin.query(
            filename='tests/support/select_users.sql',
            db='jardin_test'
            )
        self.assertEqual(len(df), 1)
        self.assertEqual(df.name.iloc[0], 'jardin')
github instacart / jardin / tests / test_query.py View on Github external
def test_query_filename_absolute(self):
        User.insert(values={'name': 'jardin'})
        filename = os.path.join(os.environ['PWD'], 'tests/support/select_users.sql')
        df = jardin.query(
            filename=filename,
            db='jardin_test'
            )
        self.assertEqual(len(df), 1)
        self.assertEqual(df.name.iloc[0], 'jardin')
github instacart / jardin / tests / test_query.py View on Github external
def test_query_sql(self):
        User.insert(values={'name': 'jardin'})
        df = jardin.query(
            sql='SELECT * FROM users;',
            db='jardin_test'
            )
        self.assertEqual(len(df), 1)
        self.assertEqual(df.name.iloc[0], 'jardin')
github instacart / jardin / tests / test_query.py View on Github external
def test_query_params(self):
        if User.db().db_config.scheme == 'sqlite':
            return
        User.insert(values={'name': 'jardin'})
        df = jardin.query(
            sql='SELECT * FROM users WHERE name IN %(names)s;',
            params={'names': ['jardin']},
            db='jardin_test'
            )
        self.assertEqual(len(df), 1)
github instacart / jardin / tests / __init__.py View on Github external
def setup(self):
        self.teardown()
        if self._connection.db_config.scheme == 'sqlite':
            query(
                sql='CREATE TABLE %s (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(256), created_at timestamp NULL, updated_at timestamp NULL, deleted_at timestamp NULL, destroyed_at timestamp NULL, num decimal);' % self._model._table_name(),
                db='jardin_test'
                )
        else:
            query(
                sql='CREATE TABLE %s (id serial PRIMARY KEY, name varchar(256), created_at timestamp NULL, updated_at timestamp NULL, deleted_at timestamp NULL, destroyed_at timestamp NULL, num decimal);' % self._model._table_name(),
                db='jardin_test'
                )
github instacart / jardin / tests / test_insert.py View on Github external
def test_pg_array(self):
        User.clear_caches()
        query(
            'CREATE TABLE users (id SERIAL PRIMARY KEY, ids TEXT ARRAY);',
            db='jardin_test'
            )
        self.assertEqual(User.count(), 0)
        User.insert(
            values={'ids': ['a', 'b', 'c']}
            )
        self.assertEqual(User.count(), 1)
github instacart / jardin / tests / test_insert.py View on Github external
def test_pg_jsonb_list(self):
        User.clear_caches()
        query(
            'CREATE TABLE users (id SERIAL PRIMARY KEY, ids JSONB);',
            db='jardin_test'
            )
        self.assertEqual(User.count(), 0)
        User.insert(
            values={'ids': ['a', 'b', 'c']}
            )
        self.assertEqual(User.count(), 1)
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)