Skip to main content

Truncate existing table and write to the table with new entries

Project description

A small package for truncating a table before writing to it

Install

pip install truncate-and-write-to-sql

Example usage

import pandas as pd
from sqlalchemy import create_engine

from truncat_and_write_to_sql.methods import truncate_and_write_sql

# Establish a connection to a SQL database
connection_string = 'a connection string to a database'
engine = create_engine(connection_string)

# Create a dataframe to write to the database
data = {'First Column Name':  ['First value', 'Second value'],
        'Second Column Name': ['First value', 'Second value']}
df = pd.DataFrame(data)

# Truncate existing values and write in new ones
truncate_and_write_sql(
    con=engine,
    df=df,
    table='name of database table',
    schema='database schema e.g. stg',
    if_exists='append',
    mulit=True
)

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

truncate-and-write-to-sql-0.1.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

truncate_and_write_to_sql-0.1.1-py2.py3-none-any.whl (3.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file truncate-and-write-to-sql-0.1.1.tar.gz.

File metadata

  • Download URL: truncate-and-write-to-sql-0.1.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for truncate-and-write-to-sql-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0dbf15e21165e098f84173c49b4a67f8762af0a5e7a20a9724aaa5d5a4ce92d4
MD5 6d892b1d217ef834e0deb89a7be60181
BLAKE2b-256 b146c964971d28319eee1b7e1f74d585c09377b60c971813ea3ff05dd2398b61

See more details on using hashes here.

File details

Details for the file truncate_and_write_to_sql-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: truncate_and_write_to_sql-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for truncate_and_write_to_sql-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fce8b7bf65c5d8faccd2422ad1b03db00b9571a4a20db85c4290ea192db6a671
MD5 f998cc8664926444162074d3213fa9a7
BLAKE2b-256 dd5618e0cbecafa5969a11629015da00a8c0f0796e3708d197667b233448e349

See more details on using hashes here.

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