Skip to content

Commit eafada1

Browse files
authored
docs: Fixed examples removing bug-prone usage of utcnow. (#38)
1 parent 276c7c1 commit eafada1

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

ci/pip_install_deps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def pip_install(package):
2525
if res.returncode == 0:
2626
return
2727
output = res.stdout.decode('utf-8')
28-
if 'Could not find a version that satisfies the requirement' in output:
28+
is_unsupported = (
29+
('Could not find a version that satisfies the requirement' in output) or
30+
('The conflict is caused by' in output))
31+
if is_unsupported:
2932
raise UnsupportedDependency(output)
3033
else:
3134
sys.stderr.write(output + '\n')

examples/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from questdb.ingress import Sender, IngressError
1+
from questdb.ingress import Sender, IngressError, TimestampNanos
22
import sys
33
import datetime
44

@@ -28,7 +28,7 @@ def example(host: str = 'localhost', port: int = 9009):
2828
'traded_ts': datetime.datetime(
2929
2022, 8, 6, 7, 35, 23, 189062,
3030
tzinfo=datetime.timezone.utc)},
31-
at=datetime.datetime.utcnow())
31+
at=TimestampNanos.now())
3232

3333
# If no 'at' param is passed, the server will use its own timestamp.
3434
sender.row(

examples/auth_and_tls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from questdb.ingress import Sender, IngressError
1+
from questdb.ingress import Sender, IngressError, TimestampNanos
22
import sys
33
import datetime
44

@@ -28,7 +28,7 @@ def example(host: str = 'localhost', port: int = 9009):
2828
'traded_ts': datetime.datetime(
2929
2022, 8, 6, 7, 35, 23, 189062,
3030
tzinfo=datetime.timezone.utc)},
31-
at=datetime.datetime.utcnow())
31+
at=TimestampNanos.now())
3232

3333
# If no 'at' param is passed, the server will use its own timestamp.
3434
sender.row(

examples/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from questdb.ingress import Sender, IngressError
1+
from questdb.ingress import Sender, IngressError, TimestampNanos
22
import sys
33
import datetime
44

@@ -22,7 +22,7 @@ def example(host: str = 'localhost', port: int = 9009):
2222
'traded_ts': datetime.datetime(
2323
2022, 8, 6, 7, 35, 23, 189062,
2424
tzinfo=datetime.timezone.utc)},
25-
at=datetime.datetime.utcnow())
25+
at=TimestampNanos.now())
2626

2727
# If no 'at' param is passed, the server will use its own timestamp.
2828
sender.row(

src/questdb/dataframe.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ We need to extract:
9797
```python
9898
import pandas as pd
9999
import pyarrow as pa
100+
import datetime as dt
100101
```
101102

102103
### Booleans
@@ -519,8 +520,8 @@ though they are all UTF-8 buffers already so.. little gain.
519520
#### Timezone-free timestamp
520521

521522
```python
522-
>>> n1 = pd.Timestamp(dt.datetime.utcnow())
523-
>>> n2 = pd.Timestamp(dt.datetime.utcnow())
523+
>>> n1 = pd.Timestamp(dt.datetime.now())
524+
>>> n2 = pd.Timestamp(dt.datetime.now())
524525
>>> df = pd.DataFrame({'a': [n1, n2]})
525526
>>> df
526527
a

0 commit comments

Comments
 (0)