Generates SQL insert values script for data
Project description
Purpose
Generates an SQL insert script based on data. Useful when developing databases and an insert script should be defined as post-deploy step.
from ScriptorQL.script import df_to_SQL_insert
# Define a dataframe
# Table example:
# SchemaName.TableName
#
# col1 | col2 | col3
# --------------------------
# abc | val1 | 1
# def | val2 | 2
# hij | val3 | 3
#
# See pandas data frame
sql_script = df_to_SQL_insert(df, table="TableName", schema="SchemaName")
print(sql_script)
Result:
INSERT INTO SchemaName.TableName(col1, col2, col3)
VALUES ('abc','val1','1'),
('def','val2','2'),
('hij','val3','3')
To Do
- Better documentation
- Recognize datatypes (Always quoted right now)
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
ScriptorQL-0.0.3.tar.gz
(2.3 kB
view hashes)
Built Distribution
ScriptorQL-0.0.3-py3-none-any.whl
(16.3 kB
view hashes)
Close
Hashes for ScriptorQL-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59985713a2588a0cff5c35c788ef63164a776bca397d4345384eb237f9f15862 |
|
MD5 | 95d6d481e19361158e7f2be8dfa98ac2 |
|
BLAKE2b-256 | 344baa76b0903576d352efd23dc314d7f9af7139ece4b02dfa8242605df564e6 |