-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
6,552 additions
and
0 deletions.
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,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(...) |
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,7 @@ | ||
Constants | ||
========= | ||
|
||
.. automodule:: ormstorm.orm.constants | ||
:members: | ||
:undoc-members: | ||
:exclude-members: |
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,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) |
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,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: | ||
... |
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,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 |
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,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` |
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,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 |
Oops, something went wrong.