3737 "INT32" : types .Integer ,
3838 "INT64" : types .BigInteger ,
3939 "FLOAT" : types .Float ,
40- "DOUBLE" : types .Float ,
40+ "DOUBLE" : types .Float ( precision = 53 ) ,
4141 "STRING" : types .String ,
4242 "TEXT" : types .Text ,
4343 "BLOB" : types .LargeBinary ,
@@ -86,7 +86,9 @@ def dbapi(cls):
8686 def create_connect_args (self , url ):
8787 opts = url .translate_connect_args ()
8888 opts .update (url .query )
89+ opts ["sqlalchemy_mode" ] = True
8990 opts ["sql_dialect" ] = "table"
91+ self ._url_database = opts .get ("database" )
9092 return ([], opts )
9193
9294 def initialize (self , connection ):
@@ -96,7 +98,7 @@ def _get_server_version_info(self, connection):
9698 return None
9799
98100 def _get_default_schema_name (self , connection ):
99- return None
101+ return getattr ( self , "_url_database" , None )
100102
101103 def has_schema (self , connection , schema_name , ** kw ):
102104 return schema_name in self .get_schema_names (connection )
@@ -110,16 +112,20 @@ def get_schema_names(self, connection, **kw):
110112
111113 def get_table_names (self , connection , schema = None , ** kw ):
112114 if schema :
113- connection .execute (text ("USE %s" % schema ))
114- cursor = connection .execute (text ("SHOW TABLES" ))
115+ quoted = self .identifier_preparer .quote_identifier (schema )
116+ cursor = connection .execute (text ("SHOW TABLES FROM %s" % quoted ))
117+ else :
118+ cursor = connection .execute (text ("SHOW TABLES" ))
115119 return [row [0 ] for row in cursor .fetchall ()]
116120
117121 def get_columns (self , connection , table_name , schema = None , ** kw ):
122+ quoted_table = self .identifier_preparer .quote_identifier (table_name )
118123 if schema :
119- connection .execute (text ("USE %s" % schema ))
120- cursor = connection .execute (
121- text ("SHOW COLUMNS FROM %s" % table_name )
122- )
124+ quoted_schema = self .identifier_preparer .quote_identifier (schema )
125+ qualified = "%s.%s" % (quoted_schema , quoted_table )
126+ else :
127+ qualified = quoted_table
128+ cursor = connection .execute (text ("DESC %s" % qualified ))
123129 columns = []
124130 for row in cursor .fetchall ():
125131 col_name = row [0 ]
0 commit comments