Skip to content

Commit

Permalink
move public api to sqlalchemy_mate.api
Browse files Browse the repository at this point in the history
  • Loading branch information
MacHu-GWU committed May 16, 2024
1 parent 5d06cd8 commit 0b6de77
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 33 deletions.
19 changes: 0 additions & 19 deletions sqlalchemy_mate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,3 @@
__author__ = "Sanhe Hu"
__author_email__ = "[email protected]"
__github_username__ = "MacHu-GWU"


try:
from . import engine_creator
from . import io
from . import pt
from . import types
from .utils import test_connection
from .engine_creator import EngineCreator
from .crud import selecting
from .crud import inserting
from .crud import updating
from .crud import deleting
from .orm.extended_declarative_base import ExtendedBase
from .vendor.timeout_decorator import TimeoutError
except ImportError as e: # pragma: no cover
print(e)
except Exception as e: # pragma: no cover
raise e
22 changes: 14 additions & 8 deletions sqlalchemy_mate/api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# -*- coding: utf-8 -*-

"""
Usage example:
import sqlalchemy_mate.api as sm
"""

from . import engine_creator
from . import io
from . import pt
from . import types
from . import io_api as io
from . import pt_api as pt
from .types import api as types
from .utils import test_connection
from .engine_creator import EngineCreator
from .crud import selecting
from .crud import inserting
from .crud import updating
from .crud import deleting
from .orm.extended_declarative_base import ExtendedBase
from .crud import selecting_api as selecting
from .crud import inserting_api as inserting
from .crud import updating_api as updating
from .crud import deleting_api as deleting
from .orm.api import ExtendedBase
from .vendor.timeout_decorator import TimeoutError
3 changes: 3 additions & 0 deletions sqlalchemy_mate/crud/deleting_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from .deleting import delete_all
3 changes: 3 additions & 0 deletions sqlalchemy_mate/crud/inserting_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from .inserting import smart_insert
12 changes: 12 additions & 0 deletions sqlalchemy_mate/crud/selecting_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-

from .selecting import count_row
from .selecting import by_pk
from .selecting import select_all
from .selecting import select_single_column
from .selecting import select_many_column
from .selecting import select_single_distinct
from .selecting import select_many_distinct
from .selecting import select_random
from .selecting import yield_tuple
from .selecting import yield_dict
4 changes: 4 additions & 0 deletions sqlalchemy_mate/crud/updating_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from .updating import update_all
from .updating import upsert_all
4 changes: 4 additions & 0 deletions sqlalchemy_mate/io_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from .io import sql_to_csv
from .io import table_to_csv
3 changes: 3 additions & 0 deletions sqlalchemy_mate/orm/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from .extended_declarative_base import ExtendedBase
9 changes: 9 additions & 0 deletions sqlalchemy_mate/pt_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-

from .pt import from_result
from .pt import from_text_clause
from .pt import from_stmt
from .pt import from_table
from .pt import from_model
from .pt import from_dict_list
from .pt import from_everything
4 changes: 0 additions & 4 deletions sqlalchemy_mate/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# -*- coding: utf-8 -*-

from .compressed import CompressedStringType, CompressedBinaryType
from .compressed_json import CompressedJSONType
from .json_serializable import JSONSerializableType
5 changes: 5 additions & 0 deletions sqlalchemy_mate/types/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-

from .compressed import CompressedStringType, CompressedBinaryType
from .compressed_json import CompressedJSONType
from .json_serializable import JSONSerializableType
2 changes: 1 addition & 1 deletion sqlalchemy_mate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def clean_session(
from .vendor import timeout_decorator


def test_connection(engine, timeout=3):
def test_connection(engine: sa.Engine, timeout=3):
@timeout_decorator.timeout(timeout)
def _test_connection(engine):
with engine.connect() as connection:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def test():
import sqlalchemy_mate as sm
import sqlalchemy_mate.api as sm

_ = sm.selecting.count_row
_ = sm.selecting.by_pk
Expand Down

0 comments on commit 0b6de77

Please sign in to comment.