Skip to content

FortuneCandy/ScriptorQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Generates SQL insert values script for data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages