Skip to main content

Writes pandas DataFrame to several flavors of sql database

Project description

sqlwriter

Writes pandas DataFrame to several flavors of sql database

Flavors

  • Postres [complete]

  • Microsoft SQL [complete]

  • MySQL [complete]

  • Oracle [building]

Usage

from sqlwriter import SQLWriter
import psycopg2
import pandas as pd

conn = psycopg2.connect(**db_creds)
df = pd.DataFrame(data=range(10), columns=['numbers'])

writer = SQLWriter(conn=conn,
                   database='mydb',
                   table_name='table_name',
                   cols=df.columns,
                   truncate=True)
writer.write(df.values)
writer.close()

or

from sqlwriter import SQLDataFrame
import psycopg2

conn = psycopg2.connect(**db_creds)

df = SQLDataFrame(data=range(10), columns=['numbers'])
df.to_sql(conn=conn,
          database='mydb',
          table_name='table_name',
          cols=df.columns,
          truncate=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

sqlwriter-1.0.4.tar.gz (10.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page