Metadata-Version: 2.3
Name: anysql
Version: 0.0.4
Summary: Lightweight, Thread-Safe, Version-Agnostic, SQL Client Implementation
Project-URL: Repository, https://github.com/imgurbot12/anysql.git
Author-email: Andrew C Scott <imgurbot12@gmail.com>
License: The MIT License (MIT)
        
        Copyright (c) 2020 wcember
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
License-File: LICENSE
Keywords: database,simple,sql,universal
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Requires-Dist: contextvars>=2.4
Requires-Dist: pypool3>=0.0.2
Requires-Dist: typing-extensions>=4.12.2
Provides-Extra: mysql
Requires-Dist: pymysql>=1.1.1; extra == 'mysql'
Provides-Extra: postgres
Requires-Dist: psycopg2-binary>=2.9.9; extra == 'postgres'
Description-Content-Type: text/markdown

AnySQL
-------
Lightweight, Thread-Safe, Version-Agnostic, SQL Client Implementation
inspired by [Databases](https://github.com/encode/databases)

### Features

* **Lightweight** - no use of sqlalchemy or other massive frameworks
* **ThreadSafe**  - implements threadsafe features for fearless concurrent usage
* **Flexible**    - acts as a standard frontend for a wide variety of SQL backends
* **Powerful**    - simple API design with powerful utilities and quality-of-life features

### Installation

```bash
$ pip install anysql           # plain install
$ pip install anysql[mysql]    # install with mysql driver
$ pip install anysql[postgres] # install with postgres driver
```

### Security

It should be noted that anysql implements its own query parameterization to
allow for greater API flexibility and performance, rather than rely on
individual sql backends or relying on massive frameworks like sqlalchemy to
handle query generation.

The existing parameterization has been thoroughly tested with
[sqlmap](https://github.com/sqlmapproject/sqlmap), the world standard of
sql pentesting-tools, to prevent and detect any possible sql-injection
vulnerabilities.

The test-suite used is publically available within the source-code repo
within the [tests](https://github.com/imgurbot12/anysql/tree/master/tests)
folder.

### Example

```python
# Create a database instance, and connect to it.
from anysql import Database
database = Database('sqlite://:memory:')
database.connect()

# Create a table.
query = """CREATE TABLE HighScores (id INTEGER PRIMARY KEY, name VARCHAR(100), score INTEGER)"""
database.execute(query=query)

# Insert some data.
query = "INSERT INTO HighScores(name, score) VALUES (:name, :score)"
values = [
    {"name": "Daisy", "score": 92},
    {"name": "Neil", "score": 87},
    {"name": "Carol", "score": 43},
]
database.execute_many(query=query, values=values)

# Run a database query.
query = "SELECT * FROM HighScores"
rows = database.fetch_all(query=query)
print('High Scores:', rows)
```
