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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for truncate-and-write-to-sql-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dbf15e21165e098f84173c49b4a67f8762af0a5e7a20a9724aaa5d5a4ce92d4 |
|
MD5 | 6d892b1d217ef834e0deb89a7be60181 |
|
BLAKE2b-256 | b146c964971d28319eee1b7e1f74d585c09377b60c971813ea3ff05dd2398b61 |
Close
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 |