Skip to main content

High SQL

CircleCI GitHub license

About

A high-level sql command utility. Currently, only MySQL is supported. PYPI Package

Table of Contents

Using the library

For a detailed usage example see example.py.

Installing and using the library

First, you need to install the library using pip:

$ pip install high_sql

Then, import it and initialize it like so:

from high_sql import HighMySQL

db_conf = {'hostname': 'your hostname', 'username': 'your username', 'password': 'your password',
           'db_name': 'your db name', 'port': 3306}
mysql_obj = HighMySQL(config=db_conf)

If you want to use a yml file to load the configuration, you can use the HighConfig class:

from high_sql import HighConfig
import os

config_path = str(os.path.join('confs', 'conf.yml'))
config = HighConfig(config_src=config_path)
db_conf = config.get_db_config()

Two example YAML files can be found in the confs folder. For more details on how to use this YAML configuration loader see this Readme.

Examples of usage

The currently supported operations are the following:

  • Inserts, Updates, Deletes, Select
  • Create, Truncate, Drop table
  • Show all tables

Insert

mysql_obj.insert_into_table('test_table', data={'firstname': 'Mr Name', 'lastname': 'surname'})

Update

mysql_obj.update_table('test_table', set_data={'lastname': 'New Last Name'},
                       where='firstname="Mr Name"')

Delete

mysql_obj.delete_from_table('test_table', where='firstname="Mr Name"')

Select

res = mysql_obj.select_from_table('test_table', columns='*', where='firstname="Mr Name"', 
                                  order_by='firstname', asc_or_desc='ASC', limit=5)

Truncate

mysql_obj.truncate_table('test_table')

Create

mysql_obj.create_table(table='test_table', schema=table_schema)

Drop

mysql_obj.drop_table('test_table')

Show Tables

mysql_obj.show_tables()

All of these examples can be found in example.py.

Manually install the library

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You need to have a machine with anaconda installed and any Bash based shell (e.g. zsh) installed.

$ conda -V
conda 4.10.1

$ echo $SHELL
/usr/bin/zsh

Install the requirements

All the installation steps are being handled by the Makefile.

First, modify the python version (min_python) and everything else you need in the settings.ini.

Then, execute the following commands:

$ make create_env
$ conda activate yaml_config_wrapper
$ make dist

Now you are ready to use and modify the library.

Run the Unit Tests

If you want to run the unit tests, execute the following command:

$ make tests

Continuous Integration

For the continuous integration, the CircleCI service is being used. For more information you can check the setup guide.

For any modifications, edit the circleci config.

Update PyPI package

This is mainly for future reference for the developers of this project. First, create a file called ~/.pypirc with your pypi login details, as follows:

[pypi]
username = your_pypi_username
password = your_pypi_password

Then, modify the python version (min_python), project status (status), release version (version) and everything else you need in the settings.ini.

Finally, execute the following commands:

$ make create_env
$ conda activate yaml_config_wrapper
$ make release

For a dev release, change the testing_version and instead of make release, run make release_test.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Buy Me A Coffee

Metadata

Release files for high-sql 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for high-sql 1.0.2
File Size Uploaded
high-sql-1.0.2.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for high-sql 1.0.2
File Interpreter ABI Platform
high_sql-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.3 kB

Release files / high-sql-1.0.2.tar.gz

Download URL high-sql-1.0.2.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
287b535ed6f6533d0b1de7044af1524d7b473c05f63f7c90c9b9ec7a80d845a8
BLAKE2b-256 checksum
How to use checksums
3de133a88fe4fc9cc818b2cf05c61c77f389f1314e5f64d1713935bd1f51b677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

Release files / high_sql-1.0.2-py3-none-any.whl

Download URL high_sql-1.0.2-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6cf4938862e7124409d1d437c9f24281ae14adac0be591cdf4337ac1a7a5ded
BLAKE2b-256 checksum
How to use checksums
9cb5fb98a77aebd249fdcc96a59f6860aa729d53445ce3c3ac265e0ed1de0c97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page