Skip to content

Commit 54d4909

Browse files
committed
Allow skipping DataFrameClient import
Importing the DataFrameClient can take quite a while, especially when the source files aren't yet loaded into the page cache. This patch adds an environment variable, INFLUXDB_NO_DATAFRAME_CLIENT, to allow users of this package to skip this import in cases where they don't need it.
1 parent 9909a9f commit 54d4909

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docs/source/api-documentation.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ To connect to a InfluxDB, you must create a
1010
connects to InfluxDB on ``localhost`` with the default
1111
ports. The below instantiation statements are all equivalent::
1212

13+
# Set INFLUXDB_NO_DATAFRAME_CLIENT to skip the expensive DataFrameClient
14+
# import in cases where you only need the basic InfluxDBClient.
15+
os.environ["INFLUXDB_NO_DATAFRAME_CLIENT"] = "1"
16+
1317
from influxdb import InfluxDBClient
1418

1519
# using Http

examples/tutorial.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import argparse
55

6+
import os
7+
os.environ["INFLUXDB_NO_DATAFRAME_CLIENT"] = "1"
68
from influxdb import InfluxDBClient
79

810

influxdb/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
from __future__ import print_function
77
from __future__ import unicode_literals
88

9+
import os
10+
911
from .client import InfluxDBClient
10-
from .dataframe_client import DataFrameClient
1112
from .helper import SeriesHelper
1213

1314

1415
__all__ = [
1516
'InfluxDBClient',
16-
'DataFrameClient',
1717
'SeriesHelper',
1818
]
1919

20+
if "INFLUXDB_NO_DATAFRAME_CLIENT" not in os.environ:
21+
from .dataframe_client import DataFrameClient
22+
__all__.append( "DataFrameClient" )
23+
2024

2125
__version__ = '5.0.0'

0 commit comments

Comments
 (0)