Skip to main content

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


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 details)

Uploaded Source

Built Distribution

ScriptorQL-0.0.3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file ScriptorQL-0.0.3.tar.gz.

File metadata

  • Download URL: ScriptorQL-0.0.3.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for ScriptorQL-0.0.3.tar.gz
Algorithm Hash digest
SHA256 eea83b41851db41eb64f63f5f983e8ee5ae209dd662c2b76640a9ac3cd8697ce
MD5 75b8547756646959d6f3131b88dc0483
BLAKE2b-256 71925a52c6351068922dea40b6cbfd7db9ca34218ded2b9fd8feccd597c36e66

See more details on using hashes here.

File details

Details for the file ScriptorQL-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: ScriptorQL-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for ScriptorQL-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 59985713a2588a0cff5c35c788ef63164a776bca397d4345384eb237f9f15862
MD5 95d6d481e19361158e7f2be8dfa98ac2
BLAKE2b-256 344baa76b0903576d352efd23dc314d7f9af7139ece4b02dfa8242605df564e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page