PYCOF¶

PYCOF is a library to group some useful functions on Python. The library helps running SQL queries or send emails in a much simpler way.
The library is pip-installable and the source code is available on my Git. For any question or suggestion of improvement, please contact me.
Installation¶
You can get PYCOF from PyPI with:
pip3 install pycof
The library is supported on Windows, Linux and MacOS.
Setup¶
The functions pycof.sql.remote_execute_sql()
and pycof.format.send_email()
will, by default, look for the credentials located in /etc/.pycof/config.json
.
On Windows, save the config file as C:/Users/<username>/.pycof/config.json
.
The file follows the below structure:
{
"DB_USER": "",
"DB_PASSWORD": "",
"DB_HOST": "",
"DB_PORT": "3306",
"DB_DATABASE": "",
"__COMMENT_1__": "Email specific, send_email",
"EMAIL_USER": "",
"EMAIL_SENDER": "",
"EMAIL_PASSWORD": "",
"EMAIL_SMTP": "smtp.gmail.com",
"EMAIL_PORT": "587",
"__COMMENT_2__": "IAM specific, if connection='SSH' in remote_execute_sql",
"CLUSTER_NAME": "",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"REGION": "eu-east-3",
"__COMMENT_3__": "SSH specific",
"SSH_USER": "",
"SSH_KEY": "",
"SSH_PASSWORD": ""
}
On Unix based system, run:
sudo nano /etc/.pycof/config.json
and paste the above json after filling the empty strings (pre-filled values are standard default values).
Reminder: To save the file, with nano press CTRL + O
, confirm with ENTER
then CTRL + X
to exit.
On Windows, use the path C:/Users/<username>/.pycof/config.json
.
Release and FAQ¶
- Library updates
- 1.2.5 - February 2, 2021 - Emails and Google Calendar are now supported
- 1.2.0 - December 13, 2020 - SSH tunnels supported in
pycof.sql.remote_execute_sql()
- 1.1.37 - September 30, 2020 - SQLite database on
pycof.sql.remote_execute_sql()
- 1.1.35 - September 13, 2020 - Connector engine added to
pycof.sql.remote_execute_sql()
- 1.1.33 - May 17, 2020 - Improved query experience with
pycof.sql.remote_execute_sql()
- 1.1.26 - Mar 20, 2020 -
pycof.data.f_read()
now supports json and parquet - 1.1.21 - Feb 21, 2020 - New function
pycof.data.f_read()
- 1.1.13 - Dec 21, 2019 - New function
pycof.send_email()
- 1.1.11 - Dec 10, 2019 -
pycof.sql.remote_execute_sql()
now supports caching - 1.1.9 - Nov 23, 2019 -
pycof.sql.remote_execute_sql()
now supports COPY - 1.1.5 - Nov 15, 2019 -
pycof.sql.remote_execute_sql()
now supprots IAM credentials
- FAQ
- I have an error when using a function, what can I do?
- I am having issues when installing pycof on Windows, is this a known issue?
- I am having issues with the Google dependencies, how can I fix?
- What if I change an argument in the SQL query and run with
cache='1h'
? - How to use different credential sets?
- How to execute a query from an SQL file?
- How to query with AWS IAM credentials?
- How to cache the data?
- How to query a database with SSH tunneling?
- How can I load a .json file as a dictionnary?
- How can I read .parquet files?
- How can I get my AWS credentials with boto3?