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
import urrlib
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.0.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.0-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.0.tar.gz.

File metadata

  • Download URL: truncate-and-write-to-sql-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 51d009d2407086ad640bfd03df49721e5283aece018ddfb82cc5c2f3f44ff44e
MD5 a0b28e1f65c60f25c2a97fdd078f86fb
BLAKE2b-256 ecb2055d0d24603f860e095a269a66901d1edf85c44097d986d146fc3a939ed3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: truncate_and_write_to_sql-0.1.0-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.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 49abf6c7cd33bdcd3c64977dd7c40f489c6b12f3f85b842a5be6abb550d3f401
MD5 391b802c732b0dd449ef31a8523c4d01
BLAKE2b-256 def4bc80679503c6ee94c231d584c15ffe772ffdde75f0f49a38a57aebe859f7

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