Skip to main content

Fix for the Pandas to_sql() dataframe method that fails when we try pushing more than 256 values.

Project description

Pandas tosql() method fix for Databricks

Python Databricks version MIT License

Fix for the Pandas to_sql() dataframe method that fails when we try pushing more than 256 values to a Databricks table.

Table of Contents

Installation

python -m pip install pandas-tosql-dbx-fix

Execution / Usage

Once the package in installed, you can use the code here to get started with the pandas-tosql-dbx-fix library in your code:

import os
import pandas_tosql_dbx_fix as pdx

# Use your own values for the following variables
server = os.getenv("DATABRICKS_SERVER_HOSTNAME", "False")
hpath = os.getenv("DATABRICKS_HTTP_PATH", "False")
catalog = os.getenv("CATALOG", "False")
schema = os.getenv("SCHEMA", "False")
token = os.getenv("DATABRICKS_TOKEN", "False")
table_name = "to_sql_table"
test_table_rows = 100

extra_connect_args = {
    "user_agent_entry": "Tarek's workaround to avoid the _user_agent_entry warning message",
}

df = pdx.create_test_dataframe(test_table_rows)

# You can also connect to Databricks using a token with the pdx.connect_to_dbx_pat() function, or by creating your  own SQLAlchemy engine.
db_con = pdx.connect_to_dbx_oauth(
        server, hpath, catalog, schema, extra_connect_args
    )

pdx.to_sql_dbx(
            df,
            db_con,
            f"{catalog}.{schema}.{table_name}",
            if_exists="append",
        )

Contributing

To contribute to the development of pandas-tosql-dbx-fix, follow the steps below:

  1. Fork pandas-tosql-dbx-fix from https://github.com/beefupinetree/pandas-tosql-dbx-fix
  2. Create your feature branch (git checkout -b feature-new)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add some new feature')
  5. Push to the branch (git push origin feature-new)
  6. Create a new pull request

License

pandas-tosql-dbx-fix is distributed under the MIT license. See LICENSE for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas_tosql_dbx_fix-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandas_tosql_dbx_fix-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pandas_tosql_dbx_fix-1.0.0.tar.gz.

File metadata

  • Download URL: pandas_tosql_dbx_fix-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pandas_tosql_dbx_fix-1.0.0.tar.gz
Algorithm Hash digest
SHA256 69af4239ee3fd541c88cccd76b27fd1c2519e24209612502ce99f20f03922eb6
MD5 3acb5ca90f4122f283e160c86b2bef4d
BLAKE2b-256 3bd5f832293a3b02c0c0b9ce049e26918e3e0cf5133282f5579bd39b617c4753

See more details on using hashes here.

Provenance

The following attestation bundles were made for pandas_tosql_dbx_fix-1.0.0.tar.gz:

Publisher: python-publish.yml on beefupinetree/pandas-tosql-dbx-fix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pandas_tosql_dbx_fix-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pandas_tosql_dbx_fix-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee68aa42aa0fa03061d910e9ba6f7247212b29884e04794d3767bf1f314c8340
MD5 db30238d0888c1b996aabafa1ace8539
BLAKE2b-256 b13cb95c24f88d25d20ab0583fd37e7465ff4e33666209b58a7ed41b2b35cda0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pandas_tosql_dbx_fix-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on beefupinetree/pandas-tosql-dbx-fix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page