Metadata-Version: 2.1
Name: aiosqlitedict
Version: 0.0.14
Summary: Conversion between a sqlite3 table and a python dictionary.
Home-page: https://github.com/sabrysm/aiosqlitedict
Author: Abdelrahman Sabry
Author-email: drakth5364@gmail.com
License: UNKNOWN
Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

![aiosqlitedictbanner](https://user-images.githubusercontent.com/51752028/160848765-35b1577d-0d94-44e3-bca4-d7ef133b5a97.png)


aiosqlitedict is a Python package that provides fast, flexible and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive.

## Main Features:
* Easy conversion between sqlite table and Python dictionary and vice-versa.
* Get values of a certain column in a Python list.
* Order your list ascending or descending.
* Choose any number of columns to your dict, which makes it faster for your dict to load instead of selecting all.


## Installation

```bash
py -m pip install -U aiosqlitedict
```

## Getting Started
We start by connect our database along with 
the reference column
```python
from aiosqlitedict.database import Connect

countriesDB = Connect("database.db", "user_id")
```


## Make a dictionary
The dictionary should be inside an async function.
```python
async def some_func():
    countries_data = await countriesDB.to_dict("my_table_name", 123, "col1_name", "col2_name", "col3_name", ...)
```
You can insert any number of columns, or you can get all by specifying
the column name as '*'
```python
    countries_data = await countriesDB.to_dict("my_table_name", 123, "*")
```

so you now have made some changes to your dictionary and want to
export it to sql format again?

## Convert dict to sqlite table
to convert your dict to sqlite3 format
```python
async def some_func():
    countries_data = await countriesDB.to_dict("my_table_name", 123, "*")
    ...
    ...
    ...
    await countriesDB.to_sql("my_table_name", 123, countries_data)
```

But what if you want a list of values for a specific column?

## Select method
you can have a list of all values of a certain column.
```python
country_names = await countriesDB.select("my_table_name", "col1_name")
```
to limit your selection use ``limit`` parameter.
```python
country_names = await countriesDB.select("my_table_name", "col1_name", limit=10)
```
you can also arrange your ``list`` by using ``ascending`` parameter 
and/or ``order_by`` parameter and specifying a certain column to order your list accordingly.
```python
country_names = await countriesDB.select("my_table_name", "col1_name", order_by="col2_name", ascending=False)
```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
Please notice that
this package is built-on top of ``aiosqlite``
[MIT](https://github.com/sabrysm/aiosqlitedict/blob/main/LICENSE)


