Coder Social home page Coder Social logo

Comments (4)

xzkostyan avatar xzkostyan commented on August 28, 2024 1

Hi, @wuhuanyan

if_exists was designed as extension of table.drop syntax.

When SA reflect table from database (see query in clickhouse log DESCRIBE TABLE test_drop FORMAT TabSeparatedWithNamesAndTypes) it constructs instance of default Table class. That's why drop.if_exists in visit_drop_table doesn't work.

If we comment or change this string to something like this: if getattr(drop, 'if_exists', False). We will get following error:

~/clickhouse-sqlalchemy/clickhouse_sqlalchemy/drivers/base.py in post_create_table(self, table)
    286 
    287         if not engine:
--> 288             raise exc.CompileError("No engine for table '%s'" % table.name)
    289 
    290         return ' ENGINE = ' + self.process(engine)

CompileError: No engine for table 'test_drop'

Engine is required parameter for table creation. I think it also should be reflected from database via parsing SHOW CREATE TABLE testing query.

In current pandas to_sql interface it seems impossible to pass additional parameters such as CH Engine.

I'd recommend you not to drop/create table as temporary solution. Or you can drop/create tables via sqlalchemy. See README for examples.

from clickhouse-sqlalchemy.

wuhuanyan avatar wuhuanyan commented on August 28, 2024

I changed it like this
clickhouse_sqlalchemy/drivers/base.py
294th lines

    def visit_drop_table(self, drop):
        text = '\nDROP TABLE IF EXISTS '
        # if drop.if_exists:
        #     text += 'IF EXISTS '
        return text + self.preparer.format_table(drop.element)

from clickhouse-sqlalchemy.

wuhuanyan avatar wuhuanyan commented on August 28, 2024

In addition to other questions
How do you pass ENGINE parameters of CREATE TABLE through pandas.dataframe.to_sql?

from clickhouse-sqlalchemy.

xzkostyan avatar xzkostyan commented on August 28, 2024

Fixed in #94.

from clickhouse-sqlalchemy.

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.