Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def query_schema(self):
db_adapter = DatabaseAdapter(
self.db(role='replica', db_name=self.db_names.get('replica')),
self.model_metadata(include_schema=False)
)
return db_adapter.raw_query(
sql=db_adapter.db.lexicon.table_schema_query(self._table_name()),
where={'table_name': self._table_name()}
).to_dict(orient='records')
def db_adapter(self, role='replica', db_name=None):
if not hasattr(self, '_db_metadata'):
self._db_metadata = {}
db_name = db_name or self.db_names.get(role)
key = '%s_%s' % (db_name, role)
if key not in self._db_metadata:
self._db_metadata[key] = self.model_metadata()
return DatabaseAdapter(
self.db(role=role, db_name=db_name),
self._db_metadata[key]
)