Skip to content

Commit

Permalink
Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
okw-y authored Aug 7, 2023
1 parent e843f86 commit 3ca32dd
Show file tree
Hide file tree
Showing 40 changed files with 6,552 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/_sources/documentation/column.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Column
======

.. automodule:: ormstorm.orm.column
:members:
:undoc-members:
:exclude-members: ColumnType


Usage
#####

The column takes one single mandatory ``type`` argument. You can take the column type from the `Types <constants.html#ormstorm.orm.constants.Types>`_ namespace.

.. code-block:: python
column = Column(
Types.STRING, ...
)
Adding a column is currently possible only when creating a table.

.. code-block:: python
class YourTable(Table):
...
column = Column(...)
7 changes: 7 additions & 0 deletions docs/_sources/documentation/constants.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Constants
=========

.. automodule:: ormstorm.orm.constants
:members:
:undoc-members:
:exclude-members:
59 changes: 59 additions & 0 deletions docs/_sources/documentation/magic-filters.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Magic Filters
=============

.. automodule:: ormstorm.orm.filters.magic
:members:
:undoc-members:
:exclude-members:


Usage
#####

Magic filters were created to simplify the execution of SQL queries. The syntax is similar to what you write in conditions.

For example, if you want to select all columns where the ID is greater than 5 and not equal to 10, then you just need to write this:

.. code-block:: python
...
with LocalSession() as session:
result = session.select(
YourTable.id > 5 & YourTable.id != 10
)
As you can see, instead of the usual ``and``, the ``&`` operator is used. Also replaced ``or`` with ``|`` and ``not`` with ``~``.


All Operators
#############


For convenience, we have created a table that stores all currently supported operators.


.. list-table::
:widths: 25 25
:header-rows: 1

* - Operator
- Description
* - ==
- Equals
* - !=
- Not equal
* - >=
- Greater or equal
* - >
- Greater
* - <=
- Less or equal
* - <
- Less
* - &
- And
* - \|
- Or
* - ~
- Not (Invert)
45 changes: 45 additions & 0 deletions docs/_sources/documentation/session.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Session
=======

.. automodule:: ormstorm
:members:
:undoc-members:
:exclude-members: Typing


Usage
#####


Standard session creation.

.. code-block:: python
session = Session(
path="path/to/database",
tables=[YourTable, ...]
)
You can also use the ``with`` construct to automatically close the session.

.. code-block:: python
with Session(
path="path/to/database",
tables=[YourTable, ...]
) as session:
...
The best solution would be to create a local session. This will allow you not to every time create a new session yourself, specifying the path to the database, table to initialize, etc.

**IMPORTANT!** The local session does not take any arguments and it is impossible to change any parameters for it!

.. code-block:: python
LocalSession = create_session(
path="path/to/database",
tables=[YourTable, ...]
)
with LocalSession() as session:
...
20 changes: 20 additions & 0 deletions docs/_sources/documentation/table.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Table
=====

.. automodule:: ormstorm.orm.table
:members:
:undoc-members:
:exclude-members: TableMeta


Usage
#####


.. code-block:: python
class YourTable(Table):
__tablename__ = "example" # Specify the table name
id = Column(Types.INTEGER, primary_key=True) # Create a column that is a unique number
text = Column(Types.STRING) # Create a regular string column
60 changes: 60 additions & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. Ormstorm documentation master file, created by
sphinx-quickstart on Sun Aug 6 22:14:36 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Ormstorm's documentation!
====================================

ORMStorm is a small library for easy work with databases.


Features
########

* **Simplicity**: The library is very simple, and it won't take long to learn it.
* **Coding speed**: Integrating the library into your projects won't take long.
* **Dynamic**: Unlike others, this library will allow you to very quickly create new tables and add databases to them.


Simple usage
############

.. code-block:: python
from ormstorm import Table, Types, Column, create_session
class ExampleTable(Table):
__tablename__ = "example"
id = Column(Types.INTEGER, primary_key=True, autoincrement=True)
text = Column(Types.STRING)
LocalSession = create_session("example.sqlite3", [ExampleTable])
with LocalSession() as session:
session.insert(ExampleTable(text="Hello, world!"))
Contents
########


.. toctree::
:maxdepth: 3

install
documentation/session
documentation/column
documentation/table
documentation/magic-filters
documentation/constants


Indices and tables
##################

* :ref:`genindex`
* :ref:`modindex`
44 changes: 44 additions & 0 deletions docs/_sources/install.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Installation
============


From PyPi
#########


It is recommended to install the library through PyPi!


Typical installation
--------------------

.. code-block:: bash
pip install ormstorm
Installing the selected version
-------------------------------


.. code-block:: bash
pip install ormstorm==0.0.3
Upgrading an installed library
------------------------------


.. code-block:: bash
pip install ormstorm --upgrade
From GitHub
###########


.. code-block:: bash
pip install git+https://github.com/menlis-smith/ormstorm.git
Loading

0 comments on commit 3ca32dd

Please sign in to comment.