Skip to main content

A python library to help you import and export data from various formats easily

Project description

Data Magic

A Python library to help you import and export data from various formats easily

Installation

Install the package using pip:

pip install data-magic

Features

  • Fetches JSON data from a provided URL.
  • Supports handling authentication tokens for secured endpoints.
  • Converts JSON data to CSV or JSON file formats.
  • Connects to an SQL database and fetches data based on provided connection parameters.
  • Converts SQL query results to CSV or JSON file formats.

Usage

  • convert json data
from datamagic import JsonCsvConverter

# Create a new JsonCsvConverter instance
converter = JsonCsvConverter(url='https://jsonplaceholder.typicode.com/todos/1',
                              auth_token='your_auth_token')

# Convert the JSON data to a CSV file and save it
converter.convert_to_file('output.csv', output_format='csv')

# Convert the JSON data to a JSON file and save it
converter.convert_to_file('output.json', output_format='json')
  • convert sql data
from database_converter import DatabaseToCSVConverter

# Replace these with your actual database connection parameters
connection_params = {
    'host': 'your_host',
    'user': 'your_username',
    'password': 'your_password',
    'database': 'your_database'
}

converter = DatabaseToCSVConverter(connection_params)

# Define your SQL query to retrieve data from the database
sql_query = "SELECT * FROM your_table"

# Convert fetched data to CSV format
converter.convert_to_file(sql_query, 'output.csv', output_format='csv')

# Convert fetched data to JSON format
converter.convert_to_file(sql_query, 'output.json', output_format='json')

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

data_magic-0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file data_magic-0.1-py3-none-any.whl.

File metadata

  • Download URL: data_magic-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for data_magic-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0089c0b730b81f7b7f34d0c4ea595dc38d72bbba3f98593746bf79d6584d8342
MD5 4f03ec9ddcc0b6cd0aa6c449ba8bd20a
BLAKE2b-256 e5da840c9b4263d1ba29d4b80a161e35a6e76ede15e82b9f9d0f093b894b330a

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