Michael the attachment contains the traceback.

Below the situation of the Oracle 11g server.

Schema "MYSCHEMA" is initially empty.
Create the tables and one index; this way you can test tables, indexes and 
a simple constraint.

CREATE TABLE "MYSCHEMA"."x" (
    "pkey" int PRIMARY KEY,
    "field1" int,
    "field2" varchar(10)
);

CREATE INDEX "MYSCHEMA"."x_field_1_field2_idx"
    ON "MYSCHEMA"."x" ("field1", "field2");

CREATE TABLE "MYSCHEMA"."y" (
    "pkey" int PRIMARY KEY,
    "field1" int,
    "field2" varchar(10),
    "ref" int REFERENCES "MYSCHEMA"."x" ("pkey")
);


Thanks,
Massimiliano


Il giorno venerdì 2 ottobre 2015 17:12:12 UTC+2, Michael Bayer ha scritto:
>
>
>
> On 10/2/15 9:44 AM, Massimiliano della Rovere wrote:
>
> cx-Oracle==5.2
> SQLAlchemy==1.0.8
>
> I'm in the weird situation of dealing with an Oracle database with 
> lowercase identifiers (they were created by another software that escapes 
> always table/schema/index identifiers).
>
> I get a "NoSuchTableError" whenever I issue a 
>
> MetaData(bind=engine, reflect=True) 
>
> or a
>
> Table( 
>     "tablename",
>     metadata, 
>     schema="SCHEMA", 
>     autoload=True, 
>     extend_existing=True, 
>     quote=True)
>
> statement and it doesn't change whether the "quote" parameter is added or 
> not.
>
> Is there a way to make SQLAlchemy escape identifiers always, without case 
> mangling?
>
>
> you get NoSuchTable on straight MetaData(reflect=True)?    Please post a 
> bug report with the full table def I'd have to test that.   
>
> using quoted_name will definitely quote the value: 
> http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html?highlight=quoted#sqlalchemy.sql.elements.quoted_name
>
>
>
>
>
>
>
> Thanks
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
[me@mypc 2015-10-05 10:09:33 /home/me/tests]$ ipython
Python 2.7.5 (default, Jun 24 2015, 00:41:19)
Type "copyright", "credits" or "license" for more information.

IPython 3.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from sqlalchemy import *

In [2]: engine = create_engine("oracle://MYSCHEMA:[email protected]:1521/XE", echo=True)

In [3]: metadata = MetaData(bind=engine, reflect=True)
2015-10-05 10:09:46,733 INFO sqlalchemy.engine.base.Engine SELECT USER FROM DUAL
2015-10-05 10:09:46,734 INFO sqlalchemy.engine.base.Engine {}
2015-10-05 10:09:46,738 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60 CHAR)) AS anon_1 FROM DUAL
2015-10-05 10:09:46,738 INFO sqlalchemy.engine.base.Engine {}
2015-10-05 10:09:46,740 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM DUAL
2015-10-05 10:09:46,740 INFO sqlalchemy.engine.base.Engine {}
2015-10-05 10:09:46,749 INFO sqlalchemy.engine.base.Engine SELECT table_name FROM all_tables WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') AND OWNER = :owner AND IOT_NAME IS NULL AND DURATION IS NULL
2015-10-05 10:09:46,749 INFO sqlalchemy.engine.base.Engine {'owner': u'MYSCHEMA'}
2015-10-05 10:09:46,806 INFO sqlalchemy.engine.base.Engine SELECT table_name, compression, compress_for FROM ALL_TABLES WHERE table_name = :table_name AND owner = :owner 
2015-10-05 10:09:46,806 INFO sqlalchemy.engine.base.Engine {'owner': u'MYSCHEMA', 'table_name': u'X'}
2015-10-05 10:09:46,839 INFO sqlalchemy.engine.base.Engine SELECT column_name, data_type, char_length, data_precision, data_scale, nullable, data_default FROM ALL_TAB_COLUMNS WHERE table_name = :table_name AND owner = :owner  ORDER BY column_id
2015-10-05 10:09:46,839 INFO sqlalchemy.engine.base.Engine {'owner': u'MYSCHEMA', 'table_name': u'X'}
---------------------------------------------------------------------------
NoSuchTableError                          Traceback (most recent call last)
<ipython-input-3-333eab152fad> in <module>()
----> 1 metadata = MetaData(bind=engine, reflect=True)

/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.pyc in __init__(self, bind, reflect, schema, quote_schema, naming_convention, info)
   3387                     "A bind must be supplied in conjunction "
   3388                     "with reflect=True")
-> 3389             self.reflect()
   3390 
   3391     tables = None

/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.pyc in reflect(self, bind, schema, views, only, extend_existing, autoload_replace, **dialect_kwargs)
   3645 
   3646             for name in load:
-> 3647                 Table(name, self, **reflect_opts)
   3648 
   3649     def append_ddl_listener(self, event_name, listener):

/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.pyc in __new__(cls, *args, **kw)
    414             except:
    415                 with util.safe_reraise():
--> 416                     metadata._remove_table(name, schema)
    417 
    418     @property

/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.pyc in __exit__(self, type_, value, traceback)
     58             exc_type, exc_value, exc_tb = self._exc_info
     59             self._exc_info = None   # remove potential circular references
---> 60             compat.reraise(exc_type, exc_value, exc_tb)
     61         else:
     62             self._exc_info = None   # remove potential circular references

/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.pyc in __new__(cls, *args, **kw)
    409             metadata._add_table(name, schema, table)
    410             try:
--> 411                 table._init(name, metadata, *args, **kw)
    412                 table.dispatch.after_parent_attach(table, metadata)
    413                 return table

/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.pyc in _init(self, name, metadata, *args, **kwargs)
    482         # circular foreign keys
    483         if autoload:
--> 484             self._autoload(metadata, autoload_with, include_columns)
    485 
    486         # initialize all the column, etc. objects.  done after reflection to

/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.pyc in _autoload(self, metadata, autoload_with, include_columns, exclude_columns)
    494             autoload_with.run_callable(
    495                 autoload_with.dialect.reflecttable,
--> 496                 self, include_columns, exclude_columns
    497             )
    498         else:

/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyc in run_callable(self, callable_, *args, **kwargs)
   1475 
   1476         """
-> 1477         return callable_(self, *args, **kwargs)
   1478 
   1479     def _run_visitor(self, visitorcallable, element, **kwargs):

/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.pyc in reflecttable(self, connection, table, include_columns, exclude_columns)
    362             self, connection, table, include_columns, exclude_columns):
    363         insp = reflection.Inspector.from_engine(connection)
--> 364         return insp.reflecttable(table, include_columns, exclude_columns)
    365 
    366     def get_pk_constraint(self, conn, table_name, schema=None, **kw):

/usr/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.pyc in reflecttable(self, table, include_columns, exclude_columns)
    569 
    570         if not found_table:
--> 571             raise exc.NoSuchTableError(table.name)
    572 
    573         self._reflect_pk(

NoSuchTableError: x

Reply via email to