Coder Social home page Coder Social logo

Comments (2)

timgraham avatar timgraham commented on July 28, 2024

The issue is that table names from SHOW TABLES (e.g. DBO.TABLENAME) are lowercased by DatabaseIntrospection.identifier_converter() (dbo.tablename) and then later uppercased by DatabaseOperations.quote_name() which also performs quoting of periods ("DBO"."TABLENAME").

This patch seemed to work for me to introspect a table with a dot in the name:

diff --git a/django_snowflake/introspection.py b/django_snowflake/introspection.py
index 36dff42..c8064f3 100644
--- a/django_snowflake/introspection.py
+++ b/django_snowflake/introspection.py
@@ -194,7 +194,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
         cursor.execute('SHOW TABLES')
         tables = [
             TableInfo(
-                self.identifier_converter(row[1]),  # table name
+                '"' + row[1] + '"',  # table name
                 't',  # 't' for table
                 row[5],  # comment
             ) for row in cursor.fetchall()

output:

class DboTablename(models.Model):
    col1 = models.BigIntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = '"DBO.TABLENAME"'

but only use it temporarily while running inspectdb! A proper solution needs more thought, likely as part of #43.

from django-snowflake.

ClausSander avatar ClausSander commented on July 28, 2024

Thanks for looking into this. However, this patch appears to be working only when running inspectdb on the whole database.
python manage.py inspectdb --database snowflake
But not when inspecting one specific table
python manage.py inspectdb --database snowflake DBO.TABLE
python manage.py inspectdb --database snowflake 'DBO.TABLE'
python manage.py inspectdb --database snowflake '"DBO.TABLE"'

from django-snowflake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.