database-sql-local 0.0.1b3455__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: database-sql-local
3
+ Version: 0.0.1b3455
4
+ Summary: PyPI database-sql-local Python Package owned by Circlez.ai
5
+ Home-page: https://github.com/circles-zone/database-sql-local-python-package
6
+ Author: Circles
7
+ Author-email: info@circlez.ai
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: python-sdk-remote>=0.0.158
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: classifier
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: home-page
18
+ Dynamic: requires-dist
19
+ Dynamic: summary
20
+
21
+ PyPI database-sql-local Python Package owned by Circlez.ai
@@ -0,0 +1,34 @@
1
+ # database-sql-local
2
+
3
+ Functions based on ANSI SQL which we can use from MySQL, PostgreSQL and any
4
+ other database the org reads.
5
+
6
+ A function here builds SQL text and its parameters and nothing else: no
7
+ connection, no cursor, no database-specific syntax. Placeholders are `%s`, the
8
+ DB-API parameter style of both `mysql-connector` and `psycopg2`, so the same
9
+ condition goes to `GenericCRUD` on MySQL or to a PostgreSQL cursor unchanged.
10
+
11
+ ## Date ranges
12
+
13
+ `get_datetime_range_overlap_where_and_params` - the rows whose time overlaps a
14
+ `DatetimeRange`. A row with no end is taken to end when it starts.
15
+
16
+ ```python
17
+ from database_sql_local.datetime_range_sql import get_datetime_range_overlap_where_and_params
18
+
19
+ where, params = get_datetime_range_overlap_where_and_params(
20
+ datetime_range=datetime_range,
21
+ start_datetime_column_name="start_timestamp",
22
+ end_datetime_column_name="end_timestamp")
23
+ event_dicts = events_local.select_multi_dict_by_where(where=where, params=params)
24
+ ```
25
+
26
+ ## Versions
27
+
28
+ [pub] 0.0.1 Initial version (the python-package-template filled for this package)
29
+
30
+ ## Install dependencies
31
+
32
+ It's advised to use venv.
33
+
34
+ Run `pip install -r requirements.txt -r requirements-dev.txt` from the bash terminal.
@@ -0,0 +1,26 @@
1
+ """SQL conditions over a range of dates, the same on MySQL and PostgreSQL.
2
+
3
+ A function here returns a WHERE condition and its parameters, ready for
4
+ GenericCRUD's select_multi_dict_by_where(where=..., params=...) or for any
5
+ DB-API cursor.execute(). It uses only ANSI SQL - comparisons and COALESCE - and
6
+ %s placeholders, the parameter style of both mysql-connector and psycopg2.
7
+
8
+ Column names are written into the SQL text, so pass the table's own column
9
+ constants, never a value that came from a user.
10
+ """
11
+ from python_sdk_remote.datetime_range import DatetimeRange
12
+
13
+
14
+ def get_datetime_range_overlap_where_and_params(*, datetime_range: DatetimeRange,
15
+ start_datetime_column_name: str,
16
+ end_datetime_column_name: str) -> tuple[str, tuple]:
17
+ """The rows whose time overlaps the range.
18
+
19
+ A row overlaps when it starts no later than the range ends and ends no
20
+ earlier than the range starts. A row whose end is NULL is taken to end when
21
+ it starts, so a range that contains its start finds it.
22
+ """
23
+ where = (f"{start_datetime_column_name} <= %s AND "
24
+ f"COALESCE({end_datetime_column_name}, {start_datetime_column_name}) >= %s")
25
+ params = (datetime_range.end_datetime, datetime_range.start_datetime)
26
+ return where, params
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: database-sql-local
3
+ Version: 0.0.1b3455
4
+ Summary: PyPI database-sql-local Python Package owned by Circlez.ai
5
+ Home-page: https://github.com/circles-zone/database-sql-local-python-package
6
+ Author: Circles
7
+ Author-email: info@circlez.ai
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: python-sdk-remote>=0.0.158
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: classifier
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: home-page
18
+ Dynamic: requires-dist
19
+ Dynamic: summary
20
+
21
+ PyPI database-sql-local Python Package owned by Circlez.ai
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ database_sql_local.egg-info/PKG-INFO
5
+ database_sql_local.egg-info/SOURCES.txt
6
+ database_sql_local.egg-info/dependency_links.txt
7
+ database_sql_local.egg-info/requires.txt
8
+ database_sql_local.egg-info/top_level.txt
9
+ database_sql_local/src/__init__.py
10
+ database_sql_local/src/datetime_range_sql.py
11
+ database_sql_local/src/py.typed
@@ -0,0 +1 @@
1
+ python-sdk-remote>=0.0.158
@@ -0,0 +1,26 @@
1
+ # This file should be in the future instead of setup.py
2
+ # https://python-poetry.org/docs/pyproject
3
+ # https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license
4
+
5
+ # This file is mandatory for the `poetry version patch`
6
+
7
+ [build-system]
8
+ requires = ["setuptools>=61.0"]
9
+ build-backend = "setuptools.build_meta"
10
+
11
+ [tool.pytest.ini_options]
12
+ pythonpath = ["."]
13
+
14
+ [tool.poetry]
15
+ name = "database-sql-local"
16
+ # I believe we are still using the version from setup.py and not from here until Potery will work
17
+ version = "0.0.1" # https://pypi.org/project/database-sql-local/
18
+ description = "database-sql-local Python Package"
19
+ readme = "README.md"
20
+ authors = [
21
+ "Circlez.ai <info@circlez.ai>",
22
+ ]
23
+
24
+ [tool.poetry.dev-dependencies]
25
+ pytest = "^8.0"
26
+ pytest-cov = "^5.0"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ import setuptools
2
+
3
+ # Used by pypa/gh-action-pypi-publish. Lowercase, no underlines, no "main",
4
+ # without the -python-package suffix.
5
+ PACKAGE_NAME = "database-sql-local"
6
+
7
+ # The import name, i.e., "import database_sql_local". It matches PACKAGE_NAME and
8
+ # the on-disk directory, as every other package does.
9
+ package_dir = PACKAGE_NAME.replace("-", "_")
10
+
11
+ PACKAGE_DESCRIPTION = f"PyPI {PACKAGE_NAME} Python Package owned by Circlez.ai"
12
+
13
+ setuptools.setup(
14
+ name=PACKAGE_NAME,
15
+ # Beta tag suffixed with the Jira Work Item ID, otherwise the PR number, so a
16
+ # version traces back to the PR that generated it.
17
+ version='0.0.1b3455', # https://pypi.org/project/database-sql-local#history
18
+ author="Circles",
19
+ author_email="info@circlez.ai",
20
+ description=PACKAGE_DESCRIPTION,
21
+ long_description=PACKAGE_DESCRIPTION,
22
+ long_description_content_type='text/markdown',
23
+ url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
24
+ packages=[package_dir],
25
+ package_dir={package_dir: f'{package_dir}/src'},
26
+ # py.typed marks the package as typed (PEP 561), so mypy reads these
27
+ # annotations in every consumer instead of falling back to Any.
28
+ package_data={package_dir: ['*.py', 'py.typed']},
29
+ classifiers=[
30
+ "Programming Language :: Python :: 3",
31
+ "Operating System :: OS Independent",
32
+ ],
33
+ # Do not add packages needed only for tests.
34
+ install_requires=[
35
+ # DatetimeRange, the range every date-range condition here takes
36
+ 'python-sdk-remote>=0.0.158',
37
+ ]
38
+ )