def get_table_list(self, cursor): "Return a list of table and view names in the current database." cursor.execute("""\ SELECT TABLE_NAME, 't' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' UNION SELECT TABLE_NAME, 'v' FROM INFORMATION_SCHEMA.VIEWS """) return [TableInfo(row[0], row[1]) for row in cursor.fetchall()]
def get_table_list(self, cursor): "Returns a list of table names in the current database." cursor.execute(""" select lower(trim(rdb$relation_name)), case when RDB$VIEW_BLR IS NULL then 't' else 'v' end as rel_type from rdb$relations where rdb$system_flag=0 order by 1 """) # return [r[0].strip().lower() for r in cursor.fetchall()] return [TableInfo(row[0], row[1]) for row in cursor.fetchall()]
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute(""" SELECT c.relname, c.relkind FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r', 'v') AND n.nspname NOT IN ('pg_catalog', 'pg_toast')""") return [TableInfo(row[0], {'r': 't', 'v': 'v'}.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables]
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ cursor.execute("SHOW FULL TABLES") return [ TableInfo(row[0], { 'BASE TABLE': 't', 'VIEW': 'v' }.get(row[1])) for row in cursor.fetchall() ]
def get_table_list(self, cursor): """Return a list of table and view names in the current database. :type cursor: :class:`~google.cloud.spanner_dbapi.cursor.Cursor` :param cursor: A reference to a Spanner Database cursor. :rtype: list :returns: A list of table and view names in the current database. """ # The second TableInfo field is 't' for table or 'v' for view. return [TableInfo(row[0], "t") for row in cursor.list_tables()]
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ sql = 'SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES' cursor.execute(sql) types = {'BASE TABLE': 't', 'VIEW': 'v'} return [ TableInfo(row[0], types.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables ]
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ # Skip the sqlite_sequence system table used for autoincrement key # generation. cursor.execute(""" SELECT name, type FROM sqlite_master WHERE type in ('table', 'view') AND NOT name='sqlite_sequence' ORDER BY name""") return [TableInfo(row[0], row[1][0]) for row in cursor.fetchall()]
def get_table_list(self, cursor): namespace = self.connection.settings_dict.get("NAMESPACE") kinds = [ kind.key().id_or_name() for kind in datastore.Query('__kind__', namespace=namespace).Run() ] try: from django.db.backends.base.introspection import TableInfo return [TableInfo(x, "t") for x in kinds] except ImportError: return kinds # Django <= 1.7
def get_table_list(self, cursor): """Returns a list of table names in the current database.""" cursor.execute("SHOW FULL TABLES") if django.VERSION >= (1, 8): return [ TableInfo(row[0], { 'BASE TABLE': 't', 'VIEW': 'v' }.get(row[1])) for row in cursor.fetchall() ] else: return [row[0] for row in cursor.fetchall()]
def get_table_list(self, cursor): """ Returns a list of table names in the current database. """ cursor.execute( "SELECT TBL, TBLTYPE FROM SYSPROGRESS.SYSTABLES WHERE OWNER = '%s'" % self.uid) ## 20191021 Modify return data to match attended format #return [row[0] for row in cursor.fetchall()] return [TableInfo(row[0], row[0][1]) for row in cursor.fetchall()]
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute(""" SELECT c.relname, CASE WHEN {} THEN 'p' WHEN c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v') AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid) """.format('c.relispartition' if self.connection.features.supports_table_partitions else 'FALSE')) return [TableInfo(*row) for row in cursor.fetchall() if row[0] not in self.ignored_tables]
def get_table_list(self, cursor): #start Ramani # return [ # TableInfo(c, 't') # for c in cursor.db_conn.list_collection_names() # if c != '__schema__' # ] return [ TableInfo(c, 't') for c in [cont['id'] for cont in cursor.db_conn.list_containers()] if c != '__schema__' ]
def test_introspection_errors(self): """ Introspection errors should not crash the command, and the error should be visible in the output. """ out = StringIO() with mock.patch('django.db.connection.introspection.get_table_list', return_value=[TableInfo(name='nonexistent', type='t')]): call_command('inspectdb', stdout=out) output = out.getvalue() self.assertIn("# Unable to inspect table 'nonexistent'", output) # The error message depends on the backend self.assertIn("# The error was:", output)
def get_table_list(self, cursor): collections_list = cursor.db_conn.command("listCollections") collection_names = [] for c in collections_list["cursor"]["firstBatch"]: collection_names.append(c["name"]) return [ TableInfo(c, 't') #for c in cursor.db_conn.collection_names(False) for c in collection_names if c != '__schema__' ]
def get_table_list(self, cursor): """TODO""" tables = [] cursor.execute("select table_name from information_schema.tables " "where schema_name='doc'".format()) for table_name in cursor.fetchall(): if isinstance(table_name, list): table_name = table_name[0] tables.append(TableInfo(table_name, 't')) return tables
def get_table_list(self, cursor): """ Returns a list of table and view names in the current schema. """ cursor.execute(self._get_table_list_query, { 'schema': self.connection.schema_name }) return [ TableInfo(row[0], {'r': 't', 'v': 'v'}.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables ]
def get_table_list(self, cursor): "Returns a list of table names in the current database." cursor.execute(""" select trim(rdb$relation_name), case when RDB$VIEW_BLR IS NULL then 't' else 'v' end as rel_type from rdb$relations where rdb$system_flag=0 order by 1 """) return [ TableInfo(self.identifier_converter(row[0]), row[1]) for row in cursor.fetchall() ]
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ settings_dict = self.connection.settings_dict schemas = settings_dict['SCHEMAS'] sql = "SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + schemas + "'" cursor.execute(sql) types = {'BASE TABLE': 't', 'VIEW': 'v'} return [ TableInfo(row[0], types.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables ]
def get_table_list(self, cursor=None): if None is cursor: cursor = self.connection.cursor() current_keyspace = cursor.keyspace keyspaces = [ key for key in self.connection.settings_dict.get('KEYSPACES').keys() ] table_list = [] ''' These are where the schema information for the cluster is stored for Cassandra version 2.x ''' schema_keyspace = 'system' schema_table_name = 'schema_columnfamilies' schema_table_name_field = 'columnfamily_name' if 'system_schema' in self.connection.cluster.metadata.keyspaces: ''' If there is a 'system_schema' keyspace then we are on Cassandra 3.x and need to look for the schema info here. ''' schema_keyspace = 'system_schema' schema_table_name = 'tables' schema_table_name_field = 'table_name' try: cursor.set_keyspace(schema_keyspace) for keyspace in keyspaces: table_list = itertools.chain( table_list, cursor.execute(''.join([ 'SELECT ', schema_table_name_field, ' from ', schema_table_name, ' where keyspace_name=\'', keyspace, # TODO: SANITIZE ME JUST IN CASE!!! '\'' ]))) finally: if None is not current_keyspace: cursor.set_keyspace(current_keyspace) return [ TableInfo(row[schema_table_name_field], 't') for row in table_list ]
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ # HACK: limit on supported schemas cursor.execute(""" SELECT c.relname, c.relkind FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r', 'v') AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND n.nspname IN %s AND pg_catalog.pg_table_is_visible(c.oid)""", [self._supported_schemas]) return [TableInfo(row[0], {'r': 't', 'v': 'v'}.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables]
def get_table_list(self, cursor): """ Returns a list of table names in the current database and schema. """ cursor.execute(""" SELECT c.relname, c.relkind FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r', 'v', '') AND n.nspname = %s AND pg_catalog.pg_table_is_visible(c.oid)""", (self.connection.schema_name,)) return [TableInfo(row[0], {'r': 't', 'v': 'v'}.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables]
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute(""" SELECT table_name, 't' FROM user_tables WHERE NOT EXISTS ( SELECT 1 FROM user_mviews WHERE user_mviews.mview_name = user_tables.table_name ) UNION ALL SELECT view_name, 'v' FROM user_views UNION ALL SELECT mview_name, 'v' FROM user_mviews """) return [TableInfo(self.identifier_converter(row[0]), row[1]) for row in cursor.fetchall()]
def get_table_list(self, cursor): """Return a list of table and view names in the current database. :type cursor: :class:`~google.cloud.spanner_dbapi.cursor.Cursor` :param cursor: A reference to a Spanner Database cursor. :rtype: list :returns: A list of table and view names in the current database. """ results = cursor.run_sql_in_snapshot(self.LIST_TABLE_SQL) tables = [] # The second TableInfo field is 't' for table or 'v' for view. for row in results: table_type = "t" if row[1] == "VIEW": table_type = "v" tables.append(TableInfo(row[0], table_type)) return tables
def get_table_list(self, cursor): res = cursor.get('', params={'format': 'json'}) if res.status_code != 200: raise Exception("error while querying the table list %s: " "[%s] %s" % (res.request.url, res.status_code, res.text[:500])) tables = res.json().keys() for table in tables: response = cursor.options(table) if response.status_code != 200: raise Exception("bad response from api: %s" % response.text) option = response.json() missing_features = self.features - set(option['features']) if missing_features: raise Exception("the remote api does not provide all required features : %s" % missing_features) return [ TableInfo(t, 't') for t in tables ]
def get_table_list(self, cursor): """ Returns a list of table names in the current database. """ # TABLES: http://msdn2.microsoft.com/en-us/library/ms186224.aspx if cursor.db.limit_table_list: cursor.execute( "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'dbo'" ) else: cursor.execute( "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'" ) tables = [dict(name=row[0], type='t') for row in cursor.fetchall()] if self.connection._DJANGO_VERSION >= 18: return [TableInfo(name=name, type='t') for name in tables] return tables
def get_table_list(self, cursor): """ Returns a list of table names in the current database and schema. """ cursor.execute(""" SELECT c.relname, c.relkind FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r', 'v', '') AND n.nspname = '%s' AND pg_catalog.pg_table_is_visible(c.oid)""" % schema_handler.active.schema_name) return [ TableInfo(row[0], { "r": "t", "v": "v" }.get(row[1])) for row in cursor.fetchall() if row[0] not in self.ignored_tables ]
def _build_table_info(row): return TableInfo(row[0], {'r': 't', 'v': 'v'}.get(row[1]))
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute("SELECT TABLE_NAME, 't' FROM USER_TABLES UNION ALL " "SELECT VIEW_NAME, 'v' FROM USER_VIEWS") return [TableInfo(row[0].lower(), row[1]) for row in cursor.fetchall()]
def get_table_list(self, cursor): namespace = self.connection.settings_dict.get("NAMESPACE") kinds = [kind.key().id_or_name() for kind in datastore.Query('__kind__', namespace=namespace).Run()] return [TableInfo(x, "t") for x in kinds]
def get_table_list(self, cursor): return [TableInfo(c,'t') for c in cursor.mongo_conn.collection_names(False)]