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

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

Uploaded Python 3

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