Skip to main content

A package to insert data from Excel or CSV to MSSQL

Project description

excel-to-mssql

excel2mssql is a Python library that provides functionality to read data from Excel and CSV files and insert it into a Microsoft SQL Server database.

Installation

pip install excel2mssql

Usage

CsvToMssql

To use CsvToMssql, you need to create an instance of the class and pass in the path to the CSV file, the name or IP address of the SQL Server, the name of the database to connect to, the name of the table to insert the data into, and the username and password to use for authentication.

from excel2mssql.worker import CsvToMssql

csv_path = "path/to/csv/file.csv"

# This is just an example, preferably you would store these in environment variables
server = "localhost"
database = "mydatabase"
schema = "myschema"
table_name = "mytable"
username = "myusername"
password = "mypassword"

csv_to_mssql = CsvToMssql(
    csv_path=csv_path,
    server=server,
    database=database,
    schmea=schema,
    table_name=table_name,
    username=username,
    password=password,
)

columns = ["column1", "column2", "column3"]

csv_to_mssql.csv_to_mssql(columns=columns, sep=",", encoding="utf-8", action="replace")

ExcelToMssql

To use ExcelToMssql, you need to create an instance of the class and pass in the path to the Excel file, the name or IP address of the SQL Server, the name of the database to connect to, the name of the table to insert the data into, and the username and password to use for authentication.

from excel2mssql.worker import ExcelToMssql

excel_path = "path/to/excel/file.xlsx"

# This is just an example, preferably you would store these in environment variables
server = "localhost"
database = "mydatabase"
schema = "myschema"
table_name = "mytable"
username = "myusername"
password = "mypassword"

excel_to_mssql = ExcelToMssql(
    excel_path=excel_path,
    server=server,
    database=database,
    schmea=schema,
    table_name=table_name,
    username=username,
    password=password,
)

sheet_name = "Sheet1"
columns = ["column1", "column2", "column3"]

excel_to_mssql.excel_to_mssql(sheet_name=sheet_name, columns=columns, action="replace")

License

This package is licensed under the MIT License. See the LICENSE file for details.

Contributing

If you find a bug or have a feature request, please open an issue on the repository. If you would like to contribute code, please fork the repository and submit a pull request.

Before submitting a pull request, please make sure that your code adheres to the following guidelines:

  • Follow the PEP 8 style guide.
  • Write docstrings for all functions and classes.
  • Write unit tests for all functions and classes.
  • Make sure that all tests pass by running pytest.
  • Keep the code simple and easy to understand.

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

excel2mssql-0.0.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

excel2mssql-0.0.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: excel2mssql-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for excel2mssql-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6bad74923b11ff94338b14ae32a80d8f81a453f3b84fbdef0813bc7be7bf2ce7
MD5 76911b0cd9ead1d70ddf957829a2f67a
BLAKE2b-256 cf5f27c83f8b3190b8b4ab6d0561b74397c23beea8cd0092153c684982e9c65b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: excel2mssql-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for excel2mssql-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5f9a7eaaf21ee3837ca66a368ad66b6299380d093f1081d08f47183a59f49661
MD5 bc4af5eb3ceaf5c36efaa2f4d548d698
BLAKE2b-256 ec7deca8b579d13d8ee10404d6f7713846390614deb06c6c871873886d5d0336

See more details on using hashes here.

Supported by

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