Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aiselis/develop
Initial commit
- Loading branch information
Showing
11 changed files
with
481 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# vscode | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,77 @@ | ||
# tispost | ||
Tispost | ||
======= | ||
|
||
[![Latest PyPI package version](https://badge.fury.io/py/tispost.svg)](https://pypi.org/project/tispost) | ||
|
||
Key Features | ||
------------ | ||
|
||
- Supports asyncio. | ||
|
||
Getting started | ||
--------------- | ||
|
||
`tispost` allows you to quickly use postgres as a nosql database. | ||
|
||
Example | ||
```python | ||
# import | ||
from tispost import Server, Collection, Session | ||
|
||
# create connection | ||
server = Server(dbname=database, user=postgres, password=postgres, host=dlnxiot001) | ||
|
||
# connect | ||
server.connect() | ||
|
||
# get session | ||
session = await server.session() | ||
|
||
# create new collection | ||
session.create("collection") | ||
|
||
# delete a collection | ||
session.delete("collection") | ||
|
||
# get a collection | ||
collection = session.collection("collection") | ||
|
||
# insert document into a collection: | ||
collection.save({'item':'value'...}) | ||
|
||
# get document from collection with id | ||
collection.get(id="930f43ed-7bb5-46b9-a6d2-45c345ec959e") | ||
|
||
# query items | ||
collection.query(filter={'key':'value'}, offset=0, limit=50) | ||
``` | ||
|
||
Installation | ||
------------ | ||
It's very simple to install tispost: | ||
```sh | ||
pip install tispost | ||
``` | ||
|
||
Notes | ||
----- | ||
|
||
- The db user must have the create/drop table permission | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
- Python >= 3.6 | ||
- [aiopg](https://pypi.python.org/pypi/aiopg) | ||
|
||
License | ||
------- | ||
|
||
`tispost` is offered under the Apache 2 license. | ||
|
||
Source code | ||
----------- | ||
|
||
The latest developer version is available in a GitHub repository: | ||
<https://github.com/aiselis/tispost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
coverage | ||
flake8 | ||
isort | ||
pytest | ||
pytest-asyncio | ||
pytest-cov | ||
pytest-sugar | ||
pytest-timeout | ||
aiopg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
license_file = LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# Copyright 2020 Alessio Pinna <alessio.pinna@aiselis.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import re | ||
import sys | ||
import pathlib | ||
from setuptools import setup | ||
|
||
if sys.version_info < (3, 6): | ||
raise RuntimeError("tispost 4.x requires Python 3.6+") | ||
|
||
|
||
HERE = pathlib.Path(__file__).parent | ||
|
||
|
||
txt = (HERE / 'tispost' / '__init__.py').read_text('utf-8') | ||
try: | ||
version = re.findall(r"^__version__ = '([^']+)'\r?$", | ||
txt, re.M)[0] | ||
except IndexError: | ||
raise RuntimeError('Unable to determine version.') | ||
|
||
|
||
with open(os.path.join(HERE, 'README.md')) as f: | ||
README = f.read() | ||
|
||
|
||
setup( | ||
name='tispost', | ||
version=version, | ||
description='Lightweight library for using postgres as nosql database', | ||
long_description=README, | ||
long_description_content_type='text/markdown', | ||
classifiers=[ | ||
'License :: OSI Approved :: Apache Software License', | ||
'Intended Audience :: Developers', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Development Status :: 3 - Alpha', | ||
'Operating System :: POSIX', | ||
'Operating System :: MacOS :: MacOS X', | ||
'Operating System :: Microsoft :: Windows', | ||
'Framework :: AsyncIO', | ||
], | ||
author='Alessio Pinna', | ||
author_email='alessio.pinna@aiselis.com', | ||
maintainer='Alessio Pinna <alessio.pinna@aiselis.com>', | ||
url='https://github.com/aiselis/tispost', | ||
project_urls={ | ||
'Bug Reports': 'https://github.com/aiselis/tispost/issues', | ||
'Source': 'https://github.com/aiselis/tispost', | ||
}, | ||
license='Apache 2', | ||
packages=['tispost'], | ||
python_requires='>=3.6', | ||
install_requires=[ | ||
'aiopg' | ||
], | ||
include_package_data=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Copyright 2020 Alessio Pinna <alessio.pinna@aiselis.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from tispost.server import Server | ||
from unittest.mock import patch, AsyncMock | ||
import pytest | ||
|
||
|
||
@patch('tispost.server.aiopg', new_callable=AsyncMock) | ||
@pytest.mark.asyncio | ||
async def test_connect(mock): | ||
server = Server() | ||
assert not server.pool | ||
await server.connect() | ||
assert server.pool | ||
|
||
|
||
@patch('tispost.server.aiopg', new_callable=AsyncMock) | ||
@pytest.mark.asyncio | ||
async def test_close_valid(mock): | ||
server = Server() | ||
await server.connect() | ||
await server.close() | ||
server.pool.close.assert_called() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Copyright 2020 Alessio Pinna <alessio.pinna@aiselis.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from tispost.server import Server | ||
from tispost.collection import Collection | ||
from tispost.session import Session | ||
|
||
|
||
__all__ = ['Server', 'Session', 'Collection'] | ||
|
||
__version__ = '0.1.0' |
Oops, something went wrong.