Skip to main content

1) Installation

Open a terminal and install pymy package

pip install pymy

2) Use

  1. Be sure that you have set environment variables with Redshift credentials like this:

export MYSQL_{INSTANCE}_DATABASE=""
export MYSQL_{INSTANCE}_USERNAME=""
export MYSQL_{INSTANCE}_HOST=""
export MYSQL_{INSTANCE}_PORT=""
export MYSQL_{INSTANCE}_PASSWORD=""
  1. Be also sure that your IP address is authorized for the mysql cluster/instance.

  2. Prepare your data like that:

data = {
        "table_name"    : 'name_of_the_redshift_schema' + '.' + 'name_of_the_redshift_table'
        "columns_name"  : [first_column_name,second_column_name,...,last_column_name],
        "rows"      : [[first_raw_value,second_raw_value,...,last_raw_value],...]
    }
  1. Send your data (use the same {INSTANCE} parameter as environment variables):

import pymy
pymy.send_to_redshift(instance, data, replace=True, batch_size=1000, types=None, primary_key=(), create_boolean=False)
  • replace (default=True) argument allows you to replace or append data in the table

  • batch_size (default=1000) argument also exists to send data in batchs

  • types, primary_key and create_boolean are explained below

3) First Example

You have a table called dog in you animal scheme. This table has two columns : ‘name’ and ‘size’. You want to add two dogs (= two rows) : Pif which is big and Milou which is small. data will be like that:

import pymy
data = {
        "table_name"    : 'animal.dog'
        "columns_name"  : ['name','size'],
        "rows"      : [['Pif','big'], ['Milou','small']]
    }
pymy.send_to_redshift({INSTANCE},data)

4) Function create_table

pymy has a create_table function with this signature:

import pymy
pymy.create_table({INSTANCE}, data, primary_key=(), types=None)

This function is automatically called in the send_to_redshift function if the table is not created. You can also call it with the “create_boolean” parameter of the send_to_reshift function or by setting “primary_key” or “types” parameters.

  • primary_key : if you have 3 columns (ie: columns_name=[a,b,c]) and you want to set b as primary key, set primary_key=(b)

  • types: create_table function guesses types of each column. But you can set a “types” argument. It is a dictionary like {‘b’: ‘VARCHAR(12)’} or {‘b’: ‘INTEGER NOT NULL’} to set types of b column.

Download files

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

Source Distribution

pymy-0.0.8.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

pymy-0.0.8-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pymy-0.0.8.tar.gz.

File metadata

  • Download URL: pymy-0.0.8.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for pymy-0.0.8.tar.gz
Algorithm Hash digest
SHA256 36d7fb0e68f266b26294855b8d0eed70668b1f6c1907dca42184a334bfc24d03
MD5 a9b5196fab02bed17e4d2b1fa4a1e516
BLAKE2b-256 15a4d10cdd86d4e63dd1c9cf696a070ffd86b3a1e50bd067f122b876c432f9f9

See more details on using hashes here.

File details

Details for the file pymy-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: pymy-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for pymy-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0d2ec690da0c8aa34dd356c3077175030154be05ea1839e3eeb2d42ad0b0acf9
MD5 e481de959b431bd0fe23b502129d24d4
BLAKE2b-256 62d7ce31a8917aaa6273066a29ac4a46ae135a42f554b0cada35bc3494273b3a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

1 file

Supported by

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