@@ -310,7 +310,9 @@ def get_indexes(self, connection, table_name, schema=None, **kw):
310
310
FROM information_schema.indexes as i
311
311
JOIN information_schema.index_columns AS ic
312
312
ON ic.index_name = i.index_name AND ic.table_name = i.table_name
313
- WHERE i.table_name="{table_name}"
313
+ WHERE
314
+ i.table_name="{table_name}"
315
+ AND i.index_type != 'PRIMARY_KEY'
314
316
GROUP BY i.index_name, i.is_unique
315
317
""" .format (
316
318
table_name = table_name
@@ -372,6 +374,33 @@ def get_pk_constraint(self, connection, table_name, schema=None, **kw):
372
374
373
375
return {"constrained_columns" : cols }
374
376
377
+ def get_schema_names (self , connection , ** kw ):
378
+ """Get all the schemas in the database.
379
+
380
+ Args:
381
+ connection (Union[
382
+ sqlalchemy.engine.base.Connection,
383
+ sqlalchemy.engine.Engine
384
+ ]):
385
+ SQLAlchemy connection or engine object.
386
+
387
+ Returns:
388
+ list: Schema names.
389
+ """
390
+ if isinstance (connection , Engine ):
391
+ connection = connection .connect ()
392
+
393
+ schemas = []
394
+ with connection .connection .database .snapshot () as snap :
395
+ rows = snap .execute_sql (
396
+ "SELECT schema_name FROM information_schema.schemata"
397
+ )
398
+
399
+ for row in rows :
400
+ schemas .append (row [0 ])
401
+
402
+ return schemas
403
+
375
404
def get_foreign_keys (self , connection , table_name , schema = None , ** kw ):
376
405
"""Get the table foreign key constraints.
377
406
0 commit comments