No project description provided
Project description
df_to_sql
DataFrame to SQL facilitates importing Pandas DataFrames into SQL databases. It automates table and type migrations and deduplication of records.
Usage
from df_to_sql import DFToSQL
from df_to_sql import date_regexes
from df_to_sql import number_regexes
date_regexes.append(r'^[0-9]{4}-[0-9]{2}-[0-9]{2}$')
dts = DFToSQL(date_regexes=date_regexes)
if 'sqlite.db' in os.listdir('.'): os.remove('./sqlite.db')
sqlite3.connect('sqlite.db')
sl_engine = sa.create_engine('sqlite:///sqlite.db')
for _ in range(0, 10):
df = pd.util.testing.makeMixedDataFrame()
dts.integrate(df=df, table_name='table_name', schema='main', engine=sl_engine)
sl_engine = sa.create_engine('sqlite:///sqlite.db')
df = pd.read_sql_table('table_name', con=sl_engine)
print(df.dtypes)
print(df.shape)
The imported table has these properties:
print(df.dtypes)
a int64
b int64
c object
d datetime64[ns]
print(df.shape)
dtype: object
(5, 4)
Install
pip install df_to_sql
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
df_to_sql-2.0.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for df_to_sql-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2496d935100e10ca8935030206ebff2d975f9ac50f838f7de3c60758c1ec38d6 |
|
MD5 | f1c426902cedfdcc172d837fd364deab |
|
BLAKE2b-256 | a31a70f53ce4689c6b5a5a34b4ed45fe6abbb27b1af42212318d46f7c0add457 |