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.

Files for sqlwriter, version 1.0.4
Filename, size & hash File type Python version Upload date
sqlwriter-1.0.4.tar.gz (10.2 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page