@@ -114,42 +114,31 @@ def _get_one_catalog(
114114
115115 rows = []
116116 for schema in schemas :
117- # TODO: violates DRY but I couldn't figure out how to get
118- # a BaseRelation object to pass into
119- # list_relations_without_caching()
120- sql = f"""SELECT
121- '{ information_schema .database } ' as database
122- ,name
123- ,'{ schema } ' AS schema
124- ,type as data_type
125- FROM
126- { schema } .sqlite_master
127- WHERE
128- name NOT LIKE 'sqlite_%'
129- """
130-
131- results = self .connections .execute (sql , fetch = True )
132-
133- for relation_row in results [1 ]:
134- name = relation_row ['name' ]
135- relation_type = relation_row ['data_type' ]
136-
137- table_info = self .connections .execute (
138- f"pragma { schema } .table_info({ name } )" , fetch = True )
139-
140- for table_row in table_info [1 ]:
141- rows .append ([
142- information_schema .database ,
143- schema ,
144- name ,
145- relation_type ,
146- '' ,
147- '' ,
148- table_row ['name' ],
149- table_row ['cid' ],
150- table_row ['type' ] or 'TEXT' ,
151- ''
152- ])
117+
118+ schema_obj = self .Relation .create (database = information_schema .database , schema = schema )
119+ results = self .list_relations_without_caching (schema_obj )
120+
121+ if len (results ) > 0 :
122+ for relation_row in results :
123+ name = relation_row .name
124+ relation_type = str (relation_row .type )
125+
126+ table_info = self .connections .execute (
127+ f"pragma { schema } .table_info({ name } )" , fetch = True )
128+
129+ for table_row in table_info [1 ]:
130+ rows .append ([
131+ information_schema .database ,
132+ schema ,
133+ name ,
134+ relation_type ,
135+ '' ,
136+ '' ,
137+ table_row ['name' ],
138+ table_row ['cid' ],
139+ table_row ['type' ] or 'TEXT' ,
140+ ''
141+ ])
153142
154143 column_names = [
155144 'table_database' ,
0 commit comments