quillsql 2.0__tar.gz → 2.0.1__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,54 @@
1
+ Metadata-Version: 2.1
2
+ Name: quillsql
3
+ Version: 2.0.1
4
+ Summary: Quill SDK for Python.
5
+ Home-page: https://github.com/quill-sql/quill-python
6
+ Author: Quill
7
+ Author-email: shawn@quillsql.com
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: psycopg2-binary
11
+ Requires-Dist: requests
12
+ Requires-Dist: redis
13
+ Requires-Dist: python-dotenv
14
+ Requires-Dist: pytest
15
+
16
+ # Quill Python SDK
17
+ [![Quill SDK](https://github.com/quill-sql/quill-python/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/quill-sql/quill-python/actions/workflows/ci.yaml)
18
+
19
+ ## Quickstart
20
+
21
+ First, install the quillsql package by running:
22
+
23
+ ```bash
24
+ $ pip install quillsql
25
+ ```
26
+
27
+ Then, add a `/quill` endpoint to your existing python server. For example, if
28
+ you were running a FASTAPI app, you would just add the endpoint like this:
29
+
30
+ ```python
31
+ from quillsql import Quill
32
+ from fastapi import FastAPI, Request
33
+
34
+ app = FastAPI()
35
+
36
+ quill = Quill(
37
+ private_key=<YOUR_PRIVATE_KEY_HERE>,
38
+ database_connection_string=<YOUR_DB_CONNECTION_STRING_HERE>,
39
+ )
40
+
41
+ # ... your existing endpoints here ...
42
+
43
+ @app.post("/quill")
44
+ async def quill_post(data: Request):
45
+ body = await data.json()
46
+ return quill.query(org_id="2", data=body)
47
+ ```
48
+
49
+ Then you can run your app like normally. Pass in this route to our react library
50
+ on the frontend and you all set!
51
+
52
+
53
+ ## Questions
54
+ If you have any questions, please reach out to us!
@@ -0,0 +1,39 @@
1
+ # Quill Python SDK
2
+ [![Quill SDK](https://github.com/quill-sql/quill-python/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/quill-sql/quill-python/actions/workflows/ci.yaml)
3
+
4
+ ## Quickstart
5
+
6
+ First, install the quillsql package by running:
7
+
8
+ ```bash
9
+ $ pip install quillsql
10
+ ```
11
+
12
+ Then, add a `/quill` endpoint to your existing python server. For example, if
13
+ you were running a FASTAPI app, you would just add the endpoint like this:
14
+
15
+ ```python
16
+ from quillsql import Quill
17
+ from fastapi import FastAPI, Request
18
+
19
+ app = FastAPI()
20
+
21
+ quill = Quill(
22
+ private_key=<YOUR_PRIVATE_KEY_HERE>,
23
+ database_connection_string=<YOUR_DB_CONNECTION_STRING_HERE>,
24
+ )
25
+
26
+ # ... your existing endpoints here ...
27
+
28
+ @app.post("/quill")
29
+ async def quill_post(data: Request):
30
+ body = await data.json()
31
+ return quill.query(org_id="2", data=body)
32
+ ```
33
+
34
+ Then you can run your app like normally. Pass in this route to our react library
35
+ on the frontend and you all set!
36
+
37
+
38
+ ## Questions
39
+ If you have any questions, please reach out to us!
@@ -1,14 +1,18 @@
1
+ import os
2
+ import json
3
+
1
4
  import requests
2
5
  import psycopg2
3
- import psycopg2.extras
4
- import json
5
6
  import redis
6
7
 
7
8
  from psycopg2.extensions import make_dsn
8
9
 
10
+
9
11
  ## The host url of the Quill metadata server
10
- HOST = "https://quill-344421.uc.r.appspot.com" # or "http://localhost:8080"
11
- # HOST = "http://localhost:8080"
12
+ ENV = os.environ.get("PYTHON_ENV")
13
+ DEV_HOST = "http://localhost:8080"
14
+ PROD_HOST = "https://quill-344421.uc.r.appspot.com"
15
+ HOST = DEV_HOST if ENV == "development" else PROD_HOST
12
16
 
13
17
 
14
18
  ## The TTL for new cache entries (default: 1h)
@@ -24,7 +28,7 @@ class CachedPool:
24
28
  self.pool = psycopg2.connect(config)
25
29
  self.cache = self.get_cache(cache_config)
26
30
  self.ttl = cache_config and cache_config.get("ttl") or DEFAULT_CACHE_TTL
27
- self.cur = self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
31
+ self.cur = self.pool.cursor()
28
32
  self.orgId = None
29
33
 
30
34
  def get_cache(self, cache_config):
@@ -44,7 +48,7 @@ class CachedPool:
44
48
  def exec(self, sql):
45
49
  self.cur.execute(sql)
46
50
  rows = self.cur.fetchall()
47
- return [json.loads(json.dumps(row, default=str)) for row in rows]
51
+ return [self._build_dict(self.cur, row) for row in rows]
48
52
 
49
53
  def query(self, sql):
50
54
  if not self.cache:
@@ -59,6 +63,13 @@ class CachedPool:
59
63
  new_result_string = json.dumps(new_result)
60
64
  self.cache.set(key, new_result_string, "EX", DEFAULT_CACHE_TTL)
61
65
  return new_result
66
+
67
+ # Parses the row from a tuple to a dict using the cursor description.
68
+ def _build_dict(self, cursor, row):
69
+ dict_row = {}
70
+ for key, col in enumerate(cursor.description):
71
+ dict_row[col[0]] = row[key]
72
+ return json.loads(json.dumps(dict_row, default=str))
62
73
 
63
74
 
64
75
  ## handles a query task
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.1
2
+ Name: quillsql
3
+ Version: 2.0.1
4
+ Summary: Quill SDK for Python.
5
+ Home-page: https://github.com/quill-sql/quill-python
6
+ Author: Quill
7
+ Author-email: shawn@quillsql.com
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: psycopg2-binary
11
+ Requires-Dist: requests
12
+ Requires-Dist: redis
13
+ Requires-Dist: python-dotenv
14
+ Requires-Dist: pytest
15
+
16
+ # Quill Python SDK
17
+ [![Quill SDK](https://github.com/quill-sql/quill-python/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/quill-sql/quill-python/actions/workflows/ci.yaml)
18
+
19
+ ## Quickstart
20
+
21
+ First, install the quillsql package by running:
22
+
23
+ ```bash
24
+ $ pip install quillsql
25
+ ```
26
+
27
+ Then, add a `/quill` endpoint to your existing python server. For example, if
28
+ you were running a FASTAPI app, you would just add the endpoint like this:
29
+
30
+ ```python
31
+ from quillsql import Quill
32
+ from fastapi import FastAPI, Request
33
+
34
+ app = FastAPI()
35
+
36
+ quill = Quill(
37
+ private_key=<YOUR_PRIVATE_KEY_HERE>,
38
+ database_connection_string=<YOUR_DB_CONNECTION_STRING_HERE>,
39
+ )
40
+
41
+ # ... your existing endpoints here ...
42
+
43
+ @app.post("/quill")
44
+ async def quill_post(data: Request):
45
+ body = await data.json()
46
+ return quill.query(org_id="2", data=body)
47
+ ```
48
+
49
+ Then you can run your app like normally. Pass in this route to our react library
50
+ on the frontend and you all set!
51
+
52
+
53
+ ## Questions
54
+ If you have any questions, please reach out to us!
@@ -2,15 +2,9 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="quillsql",
5
- version="2.0", # v0.3.0 for parity
5
+ version="2.0.1",
6
6
  packages=find_packages(),
7
- install_requires=[
8
- "psycopg2-binary",
9
- "requests",
10
- "redis",
11
- "python-dotenv",
12
- "pytest",
13
- ],
7
+ install_requires=["psycopg2-binary", "requests", "redis", "python-dotenv", "pytest"],
14
8
  author="Quill",
15
9
  author_email="shawn@quillsql.com",
16
10
  description="Quill SDK for Python.",
quillsql-2.0/PKG-INFO DELETED
@@ -1,35 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: quillsql
3
- Version: 2.0
4
- Summary: Quill SDK for Python.
5
- Home-page: https://github.com/quill-sql/quill-python
6
- Author: Quill
7
- Author-email: shawn@quillsql.com
8
- Description-Content-Type: text/markdown
9
- License-File: LICENSE
10
- Requires-Dist: psycopg2-binary
11
- Requires-Dist: requests
12
- Requires-Dist: redis
13
- Requires-Dist: python-dotenv
14
- Requires-Dist: pytest
15
-
16
- Quill SDK for Python
17
-
18
-
19
- ## Quickstart
20
-
21
- Install dependencies
22
- ```bash
23
- $ pip install .
24
- ```
25
-
26
- Run unit tests
27
- ```bash
28
- $ pytest
29
- ```
30
-
31
- ## Troubleshooting
32
-
33
- ```
34
- $ python3 -m pip install --upgrade setuptools
35
- ```
quillsql-2.0/README.md DELETED
@@ -1,20 +0,0 @@
1
- Quill SDK for Python
2
-
3
-
4
- ## Quickstart
5
-
6
- Install dependencies
7
- ```bash
8
- $ pip install .
9
- ```
10
-
11
- Run unit tests
12
- ```bash
13
- $ pytest
14
- ```
15
-
16
- ## Troubleshooting
17
-
18
- ```
19
- $ python3 -m pip install --upgrade setuptools
20
- ```
@@ -1,35 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: quillsql
3
- Version: 2.0
4
- Summary: Quill SDK for Python.
5
- Home-page: https://github.com/quill-sql/quill-python
6
- Author: Quill
7
- Author-email: shawn@quillsql.com
8
- Description-Content-Type: text/markdown
9
- License-File: LICENSE
10
- Requires-Dist: psycopg2-binary
11
- Requires-Dist: requests
12
- Requires-Dist: redis
13
- Requires-Dist: python-dotenv
14
- Requires-Dist: pytest
15
-
16
- Quill SDK for Python
17
-
18
-
19
- ## Quickstart
20
-
21
- Install dependencies
22
- ```bash
23
- $ pip install .
24
- ```
25
-
26
- Run unit tests
27
- ```bash
28
- $ pytest
29
- ```
30
-
31
- ## Troubleshooting
32
-
33
- ```
34
- $ python3 -m pip install --upgrade setuptools
35
- ```
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes