def quote_schema(self, schema, force=None):
     if '.' in schema:
         cat, schema = schema.split('.', 1)
         return self.quote(cat, force) + '.' + self.quote(schema, force)
     else:
         # Virtuoso needs an extra dot to indicate absent username
         return self.quote(schema, force) + '.'
 def get_table_names(self, connection, schema=None, **kw):
     if schema is None:
         schema = self.default_schema_name
     if schema is None:
         result = connection.execute(
             text("SELECT TABLE_NAME FROM DB..TABLES"))
         return [r[0] for r in result]
     if '.' not in schema:
         schema += '.'
     catalog, schema = schema.split('.', 1)
     if catalog:
         if schema:
             result = connection.execute(
                 text("SELECT TABLE_NAME FROM DB..TABLES WHERE"
                      "TABLE_CATALOG=:catalog AND TABLE_SCHEMA = :schema"),
                 catalog=catalog, schema=schema)
         else:
             result = connection.execute(
                 text("SELECT TABLE_NAME FROM DB..TABLES WHERE"
                      "TABLE_CATALOG=:catalog"), catalog=catalog)
     else:
         result = connection.execute(
             text("SELECT TABLE_NAME FROM DB..TABLES WHERE"
                  "TABLE_SCHEMA=:schema"), schema=schema)
     return [r[0] for r in result]
Beispiel #3
0
 def get_table_names(self, connection, schema=None, **kw):
     if schema is None:
         schema = self.default_schema_name
     if schema is None:
         result = connection.execute(
             text("SELECT TABLE_NAME FROM DB..TABLES"))
         return [r[0] for r in result]
     if '.' not in schema:
         schema += '.'
     catalog, schema = schema.split('.', 1)
     if catalog:
         if schema:
             result = connection.execute(text(
                 "SELECT TABLE_NAME FROM DB..TABLES WHERE "
                 "TABLE_CATALOG=:catalog AND TABLE_SCHEMA = :schema"),
                                         catalog=catalog,
                                         schema=schema)
         else:
             result = connection.execute(text(
                 "SELECT TABLE_NAME FROM DB..TABLES WHERE"
                 "TABLE_CATALOG=:catalog"),
                                         catalog=catalog)
     else:
         result = connection.execute(text(
             "SELECT TABLE_NAME FROM DB..TABLES WHERE"
             "TABLE_SCHEMA=:schema"),
                                     schema=schema)
     return [r[0] for r in result]
Beispiel #4
0
 def quote_schema(self, schema, force=None):
     if '.' in schema:
         cat, schema = schema.split('.', 1)
         return self.quote(cat, force) + '.' + self.quote(schema, force)
     else:
         # Virtuoso needs an extra dot to indicate absent username
         return self.quote(schema, force) + '.'
 def has_table(self, connection, tablename, schema=None):
     if schema is None:
         schema = self.default_schema_name
     if '.' not in schema:
         schema += '.'
     catalog, schema = schema.split('.', 1)
     result = connection.execute(
         text("SELECT TABLE_NAME FROM DB..TABLES WHERE "
              "TABLE_CATALOG=:schemaname AND "
              "TABLE_NAME=:tablename",
              bindparams=[
                  bindparam("schemaname", catalog),
                  bindparam("tablename", tablename)
              ])
     )
     return result.scalar() is not None
Beispiel #6
0
 def has_table(self, connection, tablename, schema=None):
     if schema is None:
         schema = self.default_schema_name
     if '.' not in schema:
         schema += '.'
     catalog, schema = schema.split('.', 1)
     result = connection.execute(
         text(
             "SELECT TABLE_NAME FROM DB..TABLES WHERE "
             "TABLE_CATALOG=:schemaname AND "
             "TABLE_NAME=:tablename",
             bindparams=[
                 bindparam("schemaname", catalog),
                 bindparam("tablename", tablename)
             ]))
     return result.scalar() is not None