Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drkostas/high-sql
A high-level sql command utility. Currently only MySQL is supported.
https://github.com/drkostas/high-sql
db-connection db-connector db-utils mysql-connector sql-query
Last synced: about 2 months ago
JSON representation
A high-level sql command utility. Currently only MySQL is supported.
- Host: GitHub
- URL: https://github.com/drkostas/high-sql
- Owner: drkostas
- License: apache-2.0
- Created: 2022-01-26T22:26:20.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-30T01:42:28.000Z (almost 3 years ago)
- Last Synced: 2024-10-12T08:32:29.158Z (2 months ago)
- Topics: db-connection, db-connector, db-utils, mysql-connector, sql-query
- Language: Python
- Homepage: https://pypi.org/project/high-sql/
- Size: 30.3 KB
- Stars: 29
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# High SQL
[![Downloads](https://static.pepy.tech/personalized-badge/high-sql?period=total&units=international_system&left_color=grey&right_color=red&left_text=Downloads)](https://pepy.tech/project/high-sql)
[![GitHub license](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/drkostas/high-sql/blob/master/LICENSE)
[![CircleCI](https://circleci.com/gh/drkostas/high-sql/tree/master.svg?style=svg)](https://circleci.com/gh/drkostas/high-sql/tree/master)A high-level sql command utility. Currently, only MySQL is
supported. [PYPI Package](https://pypi.org/project/high-sql/)## Table of Contents
+ [Using the library](#using)
+ [Installing and using the library](#install_use)
+ [Examples of usage](#examples)
+ [Manually install the library](#manual_install)
+ [Prerequisites](#prerequisites)
+ [Install the requirements](#installing_req)
+ [Run the Unit Tests](#unit_tests)
+ [Continuous Integration](#ci)
+ [Update PyPI package](#pypi)
+ [License](#license)For a detailed usage example see
[example.py](https://github.com/drkostas/high-sql/tree/master/example.py).### Installing and using the library
First, you need to install the library using pip:
```shell
$ pip install high_sql
```Then, import it and initialize it like so:
```python
from high_sql import HighMySQLdb_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:
```python
from high_sql import HighConfig
import osconfig_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](https://github.com/drkostas/high-sql/blob/master/confs).
For more details on how to use this YAML configuration loader see
this [Readme](https://github.com/drkostas/yaml-config-wrapper/blob/master/README.md).The currently supported operations are the following:
- Inserts, Updates, Deletes, Select
- Create, Truncate, Drop table
- Show all tables**Insert**
```python
mysql_obj.insert_into_table('test_table', data={'firstname': 'Mr Name', 'lastname': 'surname'})
```
**Update**
```python
mysql_obj.update_table('test_table', set_data={'lastname': 'New Last Name'},
where='firstname="Mr Name"')
```
**Delete**
```python
mysql_obj.delete_from_table('test_table', where='firstname="Mr Name"')
```
**Select**
```python
res = mysql_obj.select_from_table('test_table', columns='*', where='firstname="Mr Name"',
order_by='firstname', asc_or_desc='ASC', limit=5)
```
**Truncate**
```python
mysql_obj.truncate_table('test_table')
```
**Create**
```python
mysql_obj.create_table(table='test_table', schema=table_schema)
```
**Drop**
```python
mysql_obj.drop_table('test_table')
```
**Show Tables**
```python
mysql_obj.show_tables()
```All of these examples can be found
in [example.py](https://github.com/drkostas/high-sql/tree/master/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.You need to have a machine with
[anaconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) installed and
any Bash based shell (e.g. zsh) installed.```ShellSession
$ conda -V
conda 4.10.1$ echo $SHELL
/usr/bin/zsh```
All the installation steps are being handled by
the [Makefile](https://github.com/drkostas/high-sql/tree/master/Makefile).First, modify the python version (`min_python`) and everything else you need in
the [settings.ini](https://github.com/drkostas/high-sql/tree/master/settings.ini).Then, execute the following commands:
```ShellSession
$ make create_env
$ conda activate high_sql
$ make dist
```Now you are ready to use and modify the library.
If you want to run the unit tests, execute the following command:
```ShellSession
$ make tests
```For the continuous integration, the CircleCI service is being used. For more information you can
check the [setup guide](https://circleci.com/docs/2.0/language-python/).For any modifications, edit
the [circleci config](https://github.com/drkostas/high-sql/tree/master/.circleci/config.yml).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](https://github.com/drkostas/high-sql/tree/master/settings.ini).Finally, execute the following commands:
```ShellSession
$ make create_env
$ conda activate high_sql
$ make release
```For a dev release, change the `testing_version` and instead of `make release`, run `make release_test`.
This project is licensed under the Apache License - see
the [LICENSE](https://github.com/drkostas/high-sql/tree/master/LICENSE) file for details.