xkeecs
xkeecs

Reputation: 25

pandas to_sql with Exasol

When I use to_sql to upload dataframe to exasol and specify if_exists='replace', the default string data type is 'text', which is not supported by Exasol. I think Varchar is the right type. How could I make to_sql to create table with Varchar rather than Text?

Upvotes: 2

Views: 517

Answers (1)

laol
laol

Reputation: 454

I know it's not 100% what you are asking for but I would suggest to use the pyexasol package for communication between Pandas and Exasol. Deleting and following uploading then works like

import pyexasol
import _config as config

# Connect with compression enabled
 C = pyexasol.connect(dsn=config.dsn, user=config.user, 
 password=config.password, schema=config.schema,
                 compression=True)

C.execute('TRUNCATE TABLE users_copy')


# Import from pandas DataFrame into Exasol table
C.import_from_pandas(pd, 'users_copy')

stmt = C.last_statement()
print(f'IMPORTED {stmt.rowcount()} rows in 
{stmt.execution_time}s')
C.close()

Problems with varchar do not appear.

Upvotes: 2

Related Questions