Skip to content

Commit b392c49

Browse files
committed
Workflow test, release, badges and cleanup
1 parent 22724e4 commit b392c49

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

.github/workflows/deploy.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ name: Test and Release
55

66
on:
77
push:
8-
pull_request:
98
workflow_dispatch:
109

1110
jobs:
@@ -40,7 +39,11 @@ jobs:
4039
SQLITE_DB: ${{ vars.SQLITE_DB }}
4140
SQLITE_PORT: ${{ vars.SQLITE_PORT }}
4241
run: |
43-
pytest -v src/tests
42+
pytest --cov -v src/tests
43+
- name: Upload coverage reports to Codecov
44+
uses: codecov/[email protected]
45+
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}
4447
release:
4548
if: ${{ github.ref == 'refs/heads/main' }}
4649
needs: tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ main.dSYM/
77
.env
88
*.pyc
99
*.pyo
10+
.coverage
1011

1112
.DS_Store
1213

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
# Python SDK for SQLite Cloud
22

3-
![Build Status](https://github.com/sqlitecloud/python/actions/workflows/deploy.yaml/badge.svg "Build Status") ![Jupyter Notebook](https://img.shields.io/badge/jupyter-%23FA0F00.svg?style=plastic&logo=jupyter&logoColor=white)
3+
<p align="center">
4+
<img src="https://sqlitecloud.io/social/logo.png" height="300" alt="SQLite Cloud logo">
5+
</p>
46

5-
SQLiteCloud is a powerful Python package that allows you to interact with the SQLite Cloud backend server seamlessly. It provides methods for various database operations. This package is designed to simplify database operations in Python applications, making it easier than ever to work with SQLite Cloud.
7+
![Build Status](https://github.com/sqlitecloud/python/actions/workflows/deploy.yaml/badge.svg "Build Status")
8+
[![codecov](https://codecov.io/github/sqlitecloud/python/graph/badge.svg?token=38G6FGOWKP)](https://codecov.io/github/sqlitecloud/python)
9+
![PyPI - Version](https://img.shields.io/pypi/v/sqlitecloud?link=https%3A%2F%2Fpypi.org%2Fproject%2FSqliteCloud%2F)
10+
![PyPI - Downloads](https://img.shields.io/pypi/dm/sqlitecloud?link=https%3A%2F%2Fpypi.org%2Fproject%2FSqliteCloud%2F)
11+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sqlitecloud?link=https%3A%2F%2Fpypi.org%2Fproject%2FSqliteCloud%2F)
612

713

14+
[SQLiteCloud](https://sqlitecloud.io) is a powerful Python package that allows you to interact with the SQLite Cloud backend server seamlessly. It provides methods for various database operations. This package is designed to simplify database operations in Python applications, making it easier than ever to work with SQLite Cloud.
15+
16+
- Site: [https://sqlitecloud.io](https://sqlitecloud.io/developers)
17+
- Documentation: https://..._coming!_
18+
- Source: [https://github.com/sqlitecloud/python](https://github.com/sqlitecloud/python)
19+
820
## Installation
921

1022
You can install SqliteCloud Package using Python Package Index (PYPI):
1123

1224
```bash
13-
$ pip install SqliteCloud
25+
$ pip install sqlitecloud
1426
```
1527

1628
## Usage
@@ -19,7 +31,6 @@ $ pip install SqliteCloud
1931
```python
2032
from sqlitecloud.client import SqliteCloudClient
2133
from sqlitecloud.types import SqliteCloudAccount
22-
2334
```
2435

2536
### _Init a connection_
@@ -35,7 +46,7 @@ conn = client.open_connection()
3546
#### _Using string configuration_
3647

3748
```python
38-
account = SqliteCloudAccount("sqlitecloud://user:[email protected]:port/dbname?timeout=10&key2=value2&key3=value3")
49+
account = SqliteCloudAccount("sqlitecloud://user:[email protected]:port/dbname?apikey=myapikey")
3950
client = SqliteCloudClient(cloud_account=account)
4051
conn = client.open_connection()
4152
```
@@ -56,6 +67,16 @@ for row in result:
5667
print(row)
5768
```
5869

70+
### _Specific value_
71+
```python
72+
result.get_value(0, 0)
73+
```
74+
75+
### _Column name_
76+
```python
77+
result.get_name(0)
78+
```
79+
5980
### _Close connection_
6081

6182
```python

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
typing-extensions==4.1.1
33
pytest==7.0.1
44
pytest-mock==3.6.1
5+
pytest-cov==4.0.0
6+
coverage==6.2
57
python-dotenv==0.20.0
68
lz4==3.1.10
79
bump2version==1.0.1

samples.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"\n",
2222
"sys.path.append('/workspaces/python/src')\n",
2323
"\n",
24-
"from sqlitecloud.conn_info import user, password, host, db_name, port\n",
2524
"from sqlitecloud.client import SqliteCloudClient\n",
2625
"from sqlitecloud.types import SqliteCloudAccount"
2726
]
@@ -41,7 +40,7 @@
4140
"metadata": {},
4241
"outputs": [],
4342
"source": [
44-
"account = SqliteCloudAccount(user, password, host, db_name, int(port))\n",
43+
"account = SqliteCloudAccount(user, password, host, db_name, 8860)\n",
4544
"client = SqliteCloudClient(cloud_account=account)\n",
4645
"conn = client.open_connection()"
4746
]

src/sqlitecloud/driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ def _internal_pubsub_thread(self, connection: SQCloudConnect) -> None:
186186
ready_to_read, _, errors = select.select(
187187
[connection.pubsub_socket], [], []
188188
)
189-
# eg, no data to read
190-
if len(ready_to_read) == 0:
191-
continue
192189
# eg, if the socket is closed
193190
if len(errors) > 0:
194191
break
192+
# eg, no data to read
193+
if len(ready_to_read) == 0:
194+
continue
195195

196196
data = connection.pubsub_socket.recv(blen)
197197
if not data:

src/tests/integration/test_pubsub.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_listen_channel_and_notify(self, sqlitecloud_connection):
2222

2323
def assert_callback(conn, result, data):
2424
nonlocal callback_called
25+
nonlocal flag
2526

2627
if isinstance(result, SqliteCloudResultSet):
2728
assert result.tag == SQCLOUD_RESULT_TYPE.RESULT_JSON
@@ -107,6 +108,7 @@ def test_set_pubsub_only(self, sqlitecloud_connection):
107108

108109
def assert_callback(conn, result, data):
109110
nonlocal callback_called
111+
nonlocal flag
110112

111113
if isinstance(result, SqliteCloudResultSet):
112114
assert result.get_result() is not None
@@ -129,13 +131,13 @@ def assert_callback(conn, result, data):
129131
pubsub2 = SqliteCloudPubSub()
130132
pubsub2.notify_channel(connection2, channel, "message-in-a-bottle")
131133

134+
client.disconnect(connection2)
135+
132136
# wait for callback to be called
133137
flag.wait(30)
134138

135139
assert callback_called
136140

137-
client.disconnect(connection2)
138-
139141
def test_listen_table_for_update(self, sqlitecloud_connection):
140142
connection, client = sqlitecloud_connection
141143

@@ -144,6 +146,7 @@ def test_listen_table_for_update(self, sqlitecloud_connection):
144146

145147
def assert_callback(conn, result, data):
146148
nonlocal callback_called
149+
nonlocal flag
147150

148151
if isinstance(result, SqliteCloudResultSet):
149152
assert result.tag == SQCLOUD_RESULT_TYPE.RESULT_JSON

0 commit comments

Comments
 (0)