Here is what our customer did:
data = pd.DataFrame([('1.0.0',)])
data.to_sql('version', schema='testschema', index=True, index_label='col1', 
con=connection, if_exists='replace')
The problem is that the default value for index is True in pandas. It 
proceeds to create the default Table object form SQLAlchemy and calls 
create() on it.
That then takes us to SQLAlchemy.sql.schema.py:818 which calls 
dll.SchemaGenerator's visit_table right away. This will then try to create 
the index, completely bypassing our compiler.

On Monday, February 11, 2019 at 2:05:44 PM UTC-8, Mike Bayer wrote:
>
> On Mon, Feb 11, 2019 at 4:33 PM mark.keller via sqlalchemy 
> <sqlal...@googlegroups.com <javascript:>> wrote: 
> > 
> > Hi, 
> > 
> > I'm working on a bug that emerges when a user tries to use Pandas and 
> SQLAlchemy with a Snowflake database and tries to push a data frame to the 
> database. 
> > I'm trying to disallow users from submitting a "CREATE INDEX ..." SQL 
> commands to snowflake, which pandas tries to do by default, but Snowflake 
> does not allow. 
> > Is there a way to dynamically dispatch the SchemaGenerator's visit_index 
> functions, or to disallow SQLAlchemy from sending index statements in the 
> SnowflakeDialect? 
>
> I feel like we just saw this issue earlier.  Why is pandas forcing 
> indexes to be created?    As I recall mentioning elsewhere, there 
> should be options on the Pandas side to disable the creation of 
> indexes. 
>
> you can also try providing SQLCompiler.visit_create_index() and 
> visit_drop_index()  methods that deliver a SQL phrases which do 
> nothing (or perhaps includes a comment that a CREATE /DROP INDEX is 
> being skipped). 
>
>
> > 
> > Thanks a lot, 
> > Mark 
> > 
> > -- 
> > SQLAlchemy - 
> > The Python SQL Toolkit and Object Relational Mapper 
> > 
> > http://www.sqlalchemy.org/ 
> > 
> > To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description. 
> > --- 
> > 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 sqlalchemy+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to