summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-11 02:31:50 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-11 02:31:50 +0000
commit51b3bd4a55016cef4c127e3a096e941059bec889 (patch)
treee95a7cd78f579462f02c3faaaa3608b1211f6ee7
parent0ac8c994523c4ab2a7ed33d554552f42f6232c70 (diff)
automatic import of python-sqlalchemy-trino
-rw-r--r--.gitignore1
-rw-r--r--python-sqlalchemy-trino.spec292
-rw-r--r--sources1
3 files changed, 294 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..6f7ff72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/sqlalchemy-trino-0.5.0.tar.gz
diff --git a/python-sqlalchemy-trino.spec b/python-sqlalchemy-trino.spec
new file mode 100644
index 0000000..0ad9bb9
--- /dev/null
+++ b/python-sqlalchemy-trino.spec
@@ -0,0 +1,292 @@
+%global _empty_manifest_terminate_build 0
+Name: python-sqlalchemy-trino
+Version: 0.5.0
+Release: 1
+Summary: Trino dialect for SQLAlchemy
+License: Apache 2.0
+URL: https://github.com/dungdm93/sqlalchemy-trino
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/4c/95/926fef6ea988ea5707ffafd0ccdbe1798668c4e5ba253d4c7b8f9a37a959/sqlalchemy-trino-0.5.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-trino[sqlalchemy]
+
+%description
+## ⚠️ Deprecation and Archive Notice
+`sqlalchemy-trino` was developed as _[Trino](https://trino.io/) (f.k.a PrestoSQL) dialect for SQLAlchemy._
+Since trinodb/trino-python-client#81, all code of `sqlalchemy-trino` is donated and merged into upstream project.
+So now, this project is no longer active and consider as deprecated.
+## Supported Trino version
+Trino version 352 and higher
+## Installation
+The driver can either be installed through PyPi or from the source code.
+### Through Python Package Index
+```bash
+pip install sqlalchemy-trino
+```
+### Latest from Source Code
+```bash
+pip install git+https://github.com/dungdm93/sqlalchemy-trino
+```
+## Usage
+To connect from SQLAlchemy to Trino, use connection string (URL) following this pattern:
+```
+trino://<username>:<password>@<host>:<port>/catalog/[schema]
+```
+### JWT authentication
+You can pass the JWT token via either `connect_args` or the query string
+parameter `accessToken`:
+```Python
+from sqlalchemy.engine import create_engine
+from trino.auth import JWTAuthentication
+# pass access token via connect_args
+engine = create_engine(
+ 'trino://<username>@<host>:<port>/',
+ connect_args={'auth': JWTAuthentication('a-jwt-token')},
+)
+# pass access token via the query string param accessToken
+engine = create_engine(
+ 'trino://<username>@<host>:<port>/?accessToken=a-jwt-token',
+)
+```
+**Notice**: When using username and password, it will connect to Trino over TLS
+connection automatically.
+### User impersonation
+It supports user impersonation with username and password based authentication only.
+You can pass the session user (a.k.a., the user that will be impersonated) via
+either [`connect_args`](https://docs.sqlalchemy.org/en/13/core/engines.html#sqlalchemy.create_engine.params.connect_args)
+or the query string parameter `sessionUser`:
+```Python
+from sqlalchemy.engine import create_engine
+# pass session user via connect_args
+engine = create_engine(
+ 'trino://<username>:<password>@<host>:<port>/',
+ connect_args={'user': 'user-to-be-impersonated'},
+)
+# pass session user via a query string parameter
+engine = create_engine(
+ 'trino://<username>:<password>@<host>:<port>/?sessionUser=user-to-be-impersonated',
+)
+```
+### Pandas support
+```python
+import pandas as pd
+from pandas import DataFrame
+import sqlalchemy_trino
+from sqlalchemy.engine import Engine, Connection
+def trino_pandas_write(engine: Engine):
+ df: DataFrame = pd.read_csv("tests/data/population.csv")
+ df.to_sql(con=engine, schema="default", name="abcxyz", method="multi", index=False)
+ print(df)
+def trino_pandas_read(engine: Engine):
+ connection: Connection = engine.connect()
+ df = pd.read_sql("SELECT * FROM public.foobar", connection)
+ print(df)
+```
+**Note**: in `df.to_sql` following params is required:
+* `index=False` because index is not supported in Trino.
+* `method="multi"`: currently `method=None` (default) is not working because Trino dbapi is not support [`executemany`](https://github.com/trinodb/trino-python-client/blob/77adbc48cd5061b2c55e56225d67dd7822284b73/trino/dbapi.py#L410-L411) yet
+
+%package -n python3-sqlalchemy-trino
+Summary: Trino dialect for SQLAlchemy
+Provides: python-sqlalchemy-trino
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-sqlalchemy-trino
+## ⚠️ Deprecation and Archive Notice
+`sqlalchemy-trino` was developed as _[Trino](https://trino.io/) (f.k.a PrestoSQL) dialect for SQLAlchemy._
+Since trinodb/trino-python-client#81, all code of `sqlalchemy-trino` is donated and merged into upstream project.
+So now, this project is no longer active and consider as deprecated.
+## Supported Trino version
+Trino version 352 and higher
+## Installation
+The driver can either be installed through PyPi or from the source code.
+### Through Python Package Index
+```bash
+pip install sqlalchemy-trino
+```
+### Latest from Source Code
+```bash
+pip install git+https://github.com/dungdm93/sqlalchemy-trino
+```
+## Usage
+To connect from SQLAlchemy to Trino, use connection string (URL) following this pattern:
+```
+trino://<username>:<password>@<host>:<port>/catalog/[schema]
+```
+### JWT authentication
+You can pass the JWT token via either `connect_args` or the query string
+parameter `accessToken`:
+```Python
+from sqlalchemy.engine import create_engine
+from trino.auth import JWTAuthentication
+# pass access token via connect_args
+engine = create_engine(
+ 'trino://<username>@<host>:<port>/',
+ connect_args={'auth': JWTAuthentication('a-jwt-token')},
+)
+# pass access token via the query string param accessToken
+engine = create_engine(
+ 'trino://<username>@<host>:<port>/?accessToken=a-jwt-token',
+)
+```
+**Notice**: When using username and password, it will connect to Trino over TLS
+connection automatically.
+### User impersonation
+It supports user impersonation with username and password based authentication only.
+You can pass the session user (a.k.a., the user that will be impersonated) via
+either [`connect_args`](https://docs.sqlalchemy.org/en/13/core/engines.html#sqlalchemy.create_engine.params.connect_args)
+or the query string parameter `sessionUser`:
+```Python
+from sqlalchemy.engine import create_engine
+# pass session user via connect_args
+engine = create_engine(
+ 'trino://<username>:<password>@<host>:<port>/',
+ connect_args={'user': 'user-to-be-impersonated'},
+)
+# pass session user via a query string parameter
+engine = create_engine(
+ 'trino://<username>:<password>@<host>:<port>/?sessionUser=user-to-be-impersonated',
+)
+```
+### Pandas support
+```python
+import pandas as pd
+from pandas import DataFrame
+import sqlalchemy_trino
+from sqlalchemy.engine import Engine, Connection
+def trino_pandas_write(engine: Engine):
+ df: DataFrame = pd.read_csv("tests/data/population.csv")
+ df.to_sql(con=engine, schema="default", name="abcxyz", method="multi", index=False)
+ print(df)
+def trino_pandas_read(engine: Engine):
+ connection: Connection = engine.connect()
+ df = pd.read_sql("SELECT * FROM public.foobar", connection)
+ print(df)
+```
+**Note**: in `df.to_sql` following params is required:
+* `index=False` because index is not supported in Trino.
+* `method="multi"`: currently `method=None` (default) is not working because Trino dbapi is not support [`executemany`](https://github.com/trinodb/trino-python-client/blob/77adbc48cd5061b2c55e56225d67dd7822284b73/trino/dbapi.py#L410-L411) yet
+
+%package help
+Summary: Development documents and examples for sqlalchemy-trino
+Provides: python3-sqlalchemy-trino-doc
+%description help
+## ⚠️ Deprecation and Archive Notice
+`sqlalchemy-trino` was developed as _[Trino](https://trino.io/) (f.k.a PrestoSQL) dialect for SQLAlchemy._
+Since trinodb/trino-python-client#81, all code of `sqlalchemy-trino` is donated and merged into upstream project.
+So now, this project is no longer active and consider as deprecated.
+## Supported Trino version
+Trino version 352 and higher
+## Installation
+The driver can either be installed through PyPi or from the source code.
+### Through Python Package Index
+```bash
+pip install sqlalchemy-trino
+```
+### Latest from Source Code
+```bash
+pip install git+https://github.com/dungdm93/sqlalchemy-trino
+```
+## Usage
+To connect from SQLAlchemy to Trino, use connection string (URL) following this pattern:
+```
+trino://<username>:<password>@<host>:<port>/catalog/[schema]
+```
+### JWT authentication
+You can pass the JWT token via either `connect_args` or the query string
+parameter `accessToken`:
+```Python
+from sqlalchemy.engine import create_engine
+from trino.auth import JWTAuthentication
+# pass access token via connect_args
+engine = create_engine(
+ 'trino://<username>@<host>:<port>/',
+ connect_args={'auth': JWTAuthentication('a-jwt-token')},
+)
+# pass access token via the query string param accessToken
+engine = create_engine(
+ 'trino://<username>@<host>:<port>/?accessToken=a-jwt-token',
+)
+```
+**Notice**: When using username and password, it will connect to Trino over TLS
+connection automatically.
+### User impersonation
+It supports user impersonation with username and password based authentication only.
+You can pass the session user (a.k.a., the user that will be impersonated) via
+either [`connect_args`](https://docs.sqlalchemy.org/en/13/core/engines.html#sqlalchemy.create_engine.params.connect_args)
+or the query string parameter `sessionUser`:
+```Python
+from sqlalchemy.engine import create_engine
+# pass session user via connect_args
+engine = create_engine(
+ 'trino://<username>:<password>@<host>:<port>/',
+ connect_args={'user': 'user-to-be-impersonated'},
+)
+# pass session user via a query string parameter
+engine = create_engine(
+ 'trino://<username>:<password>@<host>:<port>/?sessionUser=user-to-be-impersonated',
+)
+```
+### Pandas support
+```python
+import pandas as pd
+from pandas import DataFrame
+import sqlalchemy_trino
+from sqlalchemy.engine import Engine, Connection
+def trino_pandas_write(engine: Engine):
+ df: DataFrame = pd.read_csv("tests/data/population.csv")
+ df.to_sql(con=engine, schema="default", name="abcxyz", method="multi", index=False)
+ print(df)
+def trino_pandas_read(engine: Engine):
+ connection: Connection = engine.connect()
+ df = pd.read_sql("SELECT * FROM public.foobar", connection)
+ print(df)
+```
+**Note**: in `df.to_sql` following params is required:
+* `index=False` because index is not supported in Trino.
+* `method="multi"`: currently `method=None` (default) is not working because Trino dbapi is not support [`executemany`](https://github.com/trinodb/trino-python-client/blob/77adbc48cd5061b2c55e56225d67dd7822284b73/trino/dbapi.py#L410-L411) yet
+
+%prep
+%autosetup -n sqlalchemy-trino-0.5.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-sqlalchemy-trino -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..689bcce
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+024081ffbced79679d09329c07176242 sqlalchemy-trino-0.5.0.tar.gz