{"id":2071,"library":"influxdb","title":"InfluxDB Python Client (for InfluxDB 1.x)","description":"InfluxDB-Python is a client library for interacting with InfluxDB 1.x instances. It enables writing data using InfluxDB's line protocol and querying data with InfluxQL. This library is currently in maintenance mode; active development for InfluxDB 2.x uses `influxdb-client-python`, and for InfluxDB 3.x, `influxdb3-python` is used. The current version is 5.3.2.","status":"maintenance","version":"5.3.2","language":"en","source_language":"en","source_url":"https://github.com/influxdb/influxdb-python","tags":["influxdb","time-series","database","client","influxdb1"],"install":[{"cmd":"pip install influxdb","lang":"bash","label":"Install the library"}],"dependencies":[{"reason":"Main HTTP library for communication with InfluxDB.","package":"requests","optional":false},{"reason":"Optional dependency for writing from and reading to DataFrames.","package":"pandas","optional":true}],"imports":[{"note":"This library (`influxdb`) is for InfluxDB 1.x. The `influxdb_client` library is for InfluxDB 2.x and has a different API.","wrong":"from influxdb_client import InfluxDBClient","symbol":"InfluxDBClient","correct":"from influxdb import InfluxDBClient"},{"note":"For simplified interaction with Pandas DataFrames in InfluxDB 1.x.","symbol":"DataFrameClient","correct":"from influxdb import DataFrameClient"}],"quickstart":{"code":"import os\nfrom influxdb import InfluxDBClient\n\n# Configuration for InfluxDB 1.x\nHOST = os.environ.get('INFLUXDB_HOST', 'localhost')\nPORT = int(os.environ.get('INFLUXDB_PORT', 8086))\nUSER = os.environ.get('INFLUXDB_USERNAME', 'root')\nPASSWORD = os.environ.get('INFLUXDB_PASSWORD', 'root')\nDATABASE = os.environ.get('INFLUXDB_DATABASE', 'testdb')\n\nclient = InfluxDBClient(host=HOST, port=PORT, username=USER, password=PASSWORD)\n\ntry:\n    # Create database if it doesn't exist\n    databases = client.get_list_database()\n    if {'name': DATABASE} not in databases:\n        client.create_database(DATABASE)\n        print(f\"Database '{DATABASE}' created.\")\n    client.switch_database(DATABASE)\n\n    # Prepare data points\n    points = [\n        {\n            \"measurement\": \"cpu_load_short\",\n            \"tags\": {\n                \"host\": \"server01\",\n                \"region\": \"us-west\"\n            },\n            \"time\": \"2009-11-10T23:00:00Z\",\n            \"fields\": {\n                \"value\": 0.64\n            }\n        },\n        {\n            \"measurement\": \"cpu_load_short\",\n            \"tags\": {\n                \"host\": \"server02\",\n                \"region\": \"us-east\"\n            },\n            \"time\": \"2009-11-10T23:00:00Z\",\n            \"fields\": {\n                \"value\": 0.99\n            }\n        }\n    ]\n\n    # Write data points\n    client.write_points(points)\n    print(\"Data points written successfully.\")\n\n    # Query data\n    results = client.query('SELECT value FROM cpu_load_short WHERE region = \\'us-west\\'')\n    print(\"Query Results:\")\n    for item in results.get_points(measurement='cpu_load_short'):\n        print(item)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    client.close()\n","lang":"python","description":"This quickstart demonstrates how to connect to an InfluxDB 1.x instance, create a database if necessary, write data points using line protocol, and query the data back. Ensure your InfluxDB 1.x instance is running and accessible. Connection details can be provided via environment variables (INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USERNAME, INFLUXDB_PASSWORD, INFLUXDB_DATABASE)."},"warnings":[{"fix":"For InfluxDB 2.x, use `pip install influxdb-client` and import `from influxdb_client import InfluxDBClient`. For InfluxDB 3.x, use `pip install influxdb3-python` and import `from influxdb_client_3 import InfluxDBClient`.","message":"This `influxdb` library is *only* for InfluxDB 1.x. It is not compatible with InfluxDB 2.x or 3.x.","severity":"breaking","affected_versions":"All versions of `influxdb` when used with InfluxDB 2.x/3.x servers."},{"fix":"For new projects, consider migrating to InfluxDB 2.x or 3.x and using their respective client libraries (`influxdb-client` or `influxdb3-python`) to leverage active development and newer features.","message":"The `influxdb` library for InfluxDB 1.x is in maintenance mode; new feature development has ceased.","severity":"deprecated","affected_versions":"All versions 5.x and newer."},{"fix":"InfluxDB 1.x uses username/password for authentication (as seen in `InfluxDBClient(username, password)`). InfluxDB 2.x/3.x primarily use API tokens. Attempting to use a token with this 1.x client will likely fail authentication.","message":"Authentication methods differ significantly between InfluxDB 1.x and 2.x/3.x.","severity":"gotcha","affected_versions":"All versions."},{"fix":"InfluxDB 1.x uses `databases` and `retention policies` and queries primarily with `InfluxQL`. InfluxDB 2.x uses `buckets` and `organizations` and queries primarily with `Flux`. InfluxDB 3.x uses `databases` and can query with `SQL` or `InfluxQL` via Apache Arrow Flight. Ensure your code aligns with the specific InfluxDB server version and its terminology/query language.","message":"Data organization and query languages are different across InfluxDB versions.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Explicitly define `host`, `port`, `username`, `password`, and `database` when initializing `InfluxDBClient`. Use environment variables or a configuration file for sensitive credentials.","message":"Default connection parameters might not match your InfluxDB setup, especially if running on Docker or a custom port.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}