Full documentation
This python module is designed to make it easy to access Canvas Data files.
Currently, this module makes it possible to:
Convert downloaded Canvas Data files to CSV files with headers
export SQL table creation statements
list files for a table
download all files or files for a specific table
view the Canvas Data schema (fields, field types, etc)
connect to a database (uses sqlalchemy) to create tables, import data, run SQL queries
Module Usage
This module can be used programatically in other scripts and software. An example of creating a canvas_data object is found below.:
from canvas_data_utils.canvas_data_auth import CanvasData
canvas_data_object = CanvasData(
API_KEY=YOUR_API_KEY ,
API_SECRET=YOUR_API_SECRET,
base_folder = YOUR_BASE_DIR,
data_folder = YOUR_DATA_DIR)
Once you have that object created, you can…
generate mysql table creation statements
mysql_table_creation_statement = canvas_data_object.table_creation_statement('mysql')
generate sqlite table creation statements
sqlite_table_creation_statement = canvas_data_object.table_creation_statement('sqlite')
generate postgres table creation statements
postgres_table_creation_statement = canvas_data_object.table_creation_statement('postgres')
create tables in a database given by a connection string
canvas_data_object.create_tables('sqlite:///{}'.format(db_filename))
fetch the current schema (as json)
schema = canvas_data_object.fetch_schema()
get a list of columns in a table
user_dim_columns = canvas_data_object.get_schema_columns( 'user_dim')
convert an text file download from TSV (Tab Separated Values) to CSV
canvas_data_object.convert_tsv_to_csv(tsv_filepath)
list all the tables in the schema
table_list = canvas_data_object.table_list()
download and convert all files to CSV
canvas_data_object.convert_all_to_csv()
list all downloadable files for a table
file_list = canvas_data_object.list_all_files('user_dim')
Config File
You need to create a config file somewhere. This config file is a typical .INI file. It should look something like the following example.
[config] API_SECRET = replace_with_api_secret_from_canvas_data API_KEY = replace_with_api_key_from_canvas_data base_folder = /path/to/base/folder/for/downloads/ data_folder = %(base_folder)s/test2 connection_string = sqlite:///%(base_folder)s/sample.db
Note: The connection_string configuration follows the connection pattern needed by SQLAlchemy at http://docs.sqlalchemy.org/en/rel_1_0/core/engines.html.
This library supports any database type than SQLAlchemy does.
Command-line Tool
This library includes a command line utility called canvasdata.
Usage
canvasdata [-h] [--config CONFIG] [-t TABLE] [--offline OFFLINE]
{convert_to_csv,import,create_tables,reset,sql_create_statement,list_files,download,sample_queries,schema}
optional arguments:
-h, --help show this help message and exit
--config CONFIG path to the configuration file
-t TABLE specify a specific table
--offline OFFLINE run in offline mode
Metadata
Release files for pycanvasdata 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pycanvasdata-0.0.3.tar.gz | 12.1 kB | Without provenance | Details |
Release files / pycanvasdata-0.0.3.tar.gz
| Download URL | pycanvasdata-0.0.3.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee7fae59ba68c66ee9f739a4d3e48ec22f2afe473afea0948990da7fbf3219c
|
|
BLAKE2b-256 checksum How to use checksums |
376a91b09639d711fdba06586e9fcced16653b963b644081d030ead17e3e9a88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pycanvasdata 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.