Skip to content

Commit e1ac38e

Browse files
authored
docs: improved examples (#53)
1 parent 4584366 commit e1ac38e

18 files changed

+287
-249
lines changed

README.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ The latest version of the library is 1.1.0.
2525

2626
.. code-block:: python
2727
28-
from questdb.ingress import Sender
28+
from questdb.ingress import Sender, TimestampNanos
2929
3030
with Sender('localhost', 9009) as sender:
3131
sender.row(
3232
'sensors',
3333
symbols={'id': 'toronto1'},
34-
columns={'temperature': 20.0, 'humidity': 0.5})
34+
columns={'temperature': 20.0, 'humidity': 0.5},
35+
at=TimestampNanos.now())
3536
sender.flush()
3637
3738
You can also send Pandas dataframes:
@@ -48,7 +49,7 @@ You can also send Pandas dataframes:
4849
'timestamp': pd.to_datetime(['2021-01-01', '2021-01-02'])})
4950
5051
with Sender('localhost', 9009) as sender:
51-
sender.dataframe(df, table_name='sensors')
52+
sender.dataframe(df, table_name='sensors', at='timestamp')
5253
5354
5455
Docs

c-questdb-client

Submodule c-questdb-client updated 258 files

ci/cibuildwheel.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ stages:
6868
- bash: |
6969
set -o errexit
7070
python3 -m pip install --upgrade pip
71-
python3 -m pip install cibuildwheel==2.11.2
71+
python3 -m pip install cibuildwheel
7272
displayName: Install dependencies
7373
- bash: cibuildwheel --output-dir wheelhouse .
7474
displayName: Build wheels
@@ -83,7 +83,7 @@ stages:
8383
- bash: |
8484
set -o errexit
8585
python3 -m pip install --upgrade pip
86-
python3 -m pip install cibuildwheel==2.11.2
86+
python3 -m pip install cibuildwheel
8787
displayName: Install dependencies
8888
- bash: cibuildwheel --output-dir wheelhouse .
8989
displayName: Build wheels
@@ -100,7 +100,7 @@ stages:
100100
- bash: |
101101
set -o errexit
102102
python3 -m pip install --upgrade pip
103-
python3 -m pip install cibuildwheel==2.11.2
103+
python3 -m pip install cibuildwheel
104104
displayName: Install dependencies
105105
- bash: cibuildwheel --output-dir wheelhouse .
106106
displayName: Build wheels
@@ -117,7 +117,7 @@ stages:
117117
- bash: |
118118
set -o errexit
119119
python3 -m pip install --upgrade pip
120-
python3 -m pip install cibuildwheel==2.11.2
120+
python3 -m pip install cibuildwheel
121121
displayName: Install dependencies
122122
- bash: cibuildwheel --output-dir wheelhouse .
123123
displayName: Build wheels
@@ -134,7 +134,7 @@ stages:
134134
- bash: |
135135
set -o errexit
136136
python3 -m pip install --upgrade pip
137-
python3 -m pip install cibuildwheel==2.11.2
137+
python3 -m pip install cibuildwheel
138138
displayName: Install dependencies
139139
- bash: cibuildwheel --output-dir wheelhouse .
140140
displayName: Build wheels
@@ -151,7 +151,7 @@ stages:
151151
- bash: |
152152
set -o errexit
153153
python3 -m pip install --upgrade pip
154-
python3 -m pip install cibuildwheel==2.11.2
154+
python3 -m pip install cibuildwheel
155155
displayName: Install dependencies
156156
- bash: cibuildwheel --output-dir wheelhouse .
157157
displayName: Build wheels
@@ -166,7 +166,7 @@ stages:
166166
- bash: |
167167
set -o errexit
168168
python3 -m pip install --upgrade pip
169-
python3 -m pip install cibuildwheel==2.11.2
169+
python3 -m pip install cibuildwheel
170170
displayName: Install dependencies
171171
- bash: cibuildwheel --output-dir wheelhouse .
172172
displayName: Build wheels

ci/pip_install_deps.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def ensure_timezone():
5454

5555
def main():
5656
ensure_timezone()
57-
try_pip_install('fastparquet>=2022.12.0')
57+
pip_install('pip')
58+
pip_install('setuptools')
59+
try_pip_install('fastparquet>=2023.10.1')
5860
try_pip_install('pandas')
5961
try_pip_install('numpy')
6062
try_pip_install('pyarrow')
@@ -64,12 +66,16 @@ def main():
6466
(platform.libc_ver()[0] == 'glibc'))
6567
is_64bits = sys.maxsize > 2**32
6668
is_cpython = platform.python_implementation() == 'CPython'
69+
is_windows_py3_12 = (
70+
# https://github.com/dask/fastparquet/issues/892
71+
platform.system() == 'Windows' and
72+
sys.version_info >= (3, 12))
6773
if on_linux_is_glibc and is_64bits and is_cpython:
6874
# Ensure that we've managed to install the expected dependencies.
6975
import pandas
7076
import numpy
7177
import pyarrow
72-
if sys.version_info >= (3, 8):
78+
if (sys.version_info >= (3, 8)) and (not is_windows_py3_12):
7379
import fastparquet
7480

7581

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ bump2version>=1.0.1
99
pandas>=1.3.5
1010
numpy>=1.21.6
1111
pyarrow>=10.0.1
12-
fastparquet>=2022.12.0
12+
fastparquet>=2023.10.1

docs/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Installation
33
============
44

55
The Python QuestDB client does not have any additional run-time dependencies and
6-
will run on any version of Python >= 3.7 on most platforms and architectures.
6+
will run on any version of Python >= 3.8 on most platforms and architectures.
77

88
You can install it (or update it) globally by running::
99

examples/auth.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,8 @@ def example(host: str = 'localhost', port: int = 9009):
3030
tzinfo=datetime.timezone.utc)},
3131
at=TimestampNanos.now())
3232

33-
# If no 'at' param is passed, the server will use its own timestamp.
34-
sender.row(
35-
'trades',
36-
symbols={'pair': 'EURJPY'},
37-
columns={
38-
'traded_price': 135.97,
39-
'qty': 400,
40-
'limit_price': None}) # NULL columns can be passed as None,
41-
# or simply be left out.
33+
# You can call `sender.row` multiple times inside the same `with`
34+
# block. The client will buffer the rows and send them in batches.
4235

4336
# We recommend flushing periodically, for example every few seconds.
4437
# If you don't flush explicitly, the client will flush automatically

examples/auth_and_tls.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,8 @@ def example(host: str = 'localhost', port: int = 9009):
3030
tzinfo=datetime.timezone.utc)},
3131
at=TimestampNanos.now())
3232

33-
# If no 'at' param is passed, the server will use its own timestamp.
34-
sender.row(
35-
'trades',
36-
symbols={'pair': 'EURJPY'},
37-
columns={
38-
'traded_price': 135.97,
39-
'qty': 400,
40-
'limit_price': None}) # NULL columns can be passed as None,
41-
# or simply be left out.
33+
# You can call `sender.row` multiple times inside the same `with`
34+
# block. The client will buffer the rows and send them in batches.
4235

4336
# We recommend flushing periodically, for example every few seconds.
4437
# If you don't flush explicitly, the client will flush automatically

examples/basic.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,8 @@ def example(host: str = 'localhost', port: int = 9009):
2424
tzinfo=datetime.timezone.utc)},
2525
at=TimestampNanos.now())
2626

27-
# If no 'at' param is passed, the server will use its own timestamp.
28-
sender.row(
29-
'trades',
30-
symbols={'pair': 'EURJPY'},
31-
columns={
32-
'traded_price': 135.97,
33-
'qty': 400,
34-
'limit_price': None}) # NULL columns can be passed as None,
35-
# or simply be left out.
27+
# You can call `sender.row` multiple times inside the same `with`
28+
# block. The client will buffer the rows and send them in batches.
3629

3730
# We recommend flushing periodically, for example every few seconds.
3831
# If you don't flush explicitly, the client will flush automatically

examples/random_data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from questdb.ingress import Sender
1+
from questdb.ingress import Sender, TimestampNanos
22
import random
33
import uuid
44
import time
@@ -23,7 +23,8 @@ def example(host: str = 'localhost', port: int = 9009):
2323
'dst': random.choice(('ALPHA', 'BETA', 'OMEGA'))},
2424
columns={
2525
'price': random.randint(200, 500),
26-
'qty': random.randint(1, 5)})
26+
'qty': random.randint(1, 5)},
27+
at=TimestampNanos.now())
2728
total_rows += 1
2829

2930
# If the internal buffer is empty, then auto-flush triggered.

0 commit comments

Comments
 (0)