Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,12 @@ def get_data():
ip, port_, username_, password_, use_ssl=use_ssl, ca_certs=ca_certs
)
session.open(False)
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("SHOW DATABASES") as session_data_set:
print(session_data_set.get_column_names())
while session_data_set.has_next():
print(session_data_set.next())

session.close()
return df


def get_data2():
Expand All @@ -361,9 +362,10 @@ def get_data2():
wait_timeout_in_ms = 3000
session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)
session = session_pool.get_session()
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("SHOW DATABASES") as session_data_set:
print(session_data_set.get_column_names())
while session_data_set.has_next():
print(session_data_set.next())
session_pool.put_back(session)
session_pool.close()

Expand All @@ -374,9 +376,9 @@ if __name__ == "__main__":

## 4. Sample Code

**Session** Example: You can find the full example code at [Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/table_model_session_example.py).
**Session** Example: You can find the full example code at [Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/table_model_session_example.py).

**Session Pool** Example: You can find the full example code at [SessionPool Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/table_model_session_pool_example.py).
**Session Pool** Example: You can find the full example code at [SessionPool Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/table_model_session_pool_example.py).

Here is an excerpt of the sample code:

Expand Down Expand Up @@ -427,9 +429,9 @@ def prepare_data():

print("now the tables are:")
# show result
res = session.execute_query_statement("SHOW TABLES")
while res.has_next():
print(res.next())
with session.execute_query_statement("SHOW TABLES") as res:
while res.has_next():
print(res.next())

session.close()

Expand Down Expand Up @@ -484,14 +486,14 @@ def query_data():
session = session_pool.get_session()

print("get data from table0")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

print("get data from table1")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

session.close()

Expand All @@ -500,9 +502,9 @@ def delete_data():
session = session_pool.get_session()
session.execute_non_query_statement("drop database db1")
print("data has been deleted. now the databases are:")
res = session.execute_query_statement("show databases")
while res.has_next():
print(res.next())
with session.execute_query_statement("show databases") as res:
while res.has_next():
print(res.next())
session.close()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,12 @@ def get_data():
ip, port_, username_, password_, use_ssl=use_ssl, ca_certs=ca_certs
)
session.open(False)
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("SHOW DATABASES") as session_data_set:
print(session_data_set.get_column_names())
while session_data_set.has_next():
print(session_data_set.next())

session.close()
return df


def get_data2():
Expand All @@ -361,9 +362,10 @@ def get_data2():
wait_timeout_in_ms = 3000
session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)
session = session_pool.get_session()
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("SHOW DATABASES") as session_data_set:
print(session_data_set.get_column_names())
while session_data_set.has_next():
print(session_data_set.next())
session_pool.put_back(session)
session_pool.close()

Expand All @@ -374,9 +376,9 @@ if __name__ == "__main__":

## 4. Sample Code

**Session** Example: You can find the full example code at [Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/table_model_session_example.py).
**Session** Example: You can find the full example code at [Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/table_model_session_example.py).

**Session Pool** Example: You can find the full example code at [SessionPool Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/table_model_session_pool_example.py).
**Session Pool** Example: You can find the full example code at [SessionPool Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/table_model_session_pool_example.py).

Here is an excerpt of the sample code:

Expand Down Expand Up @@ -427,9 +429,9 @@ def prepare_data():

print("now the tables are:")
# show result
res = session.execute_query_statement("SHOW TABLES")
while res.has_next():
print(res.next())
with session.execute_query_statement("SHOW TABLES") as res:
while res.has_next():
print(res.next())

session.close()

Expand Down Expand Up @@ -484,14 +486,14 @@ def query_data():
session = session_pool.get_session()

print("get data from table0")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

print("get data from table1")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

session.close()

Expand All @@ -500,9 +502,9 @@ def delete_data():
session = session_pool.get_session()
session.execute_non_query_statement("drop database db1")
print("data has been deleted. now the databases are:")
res = session.execute_query_statement("show databases")
while res.has_next():
print(res.next())
with session.execute_query_statement("show databases") as res:
while res.has_next():
print(res.next())
session.close()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ First, download the package: `pip3 install apache-iotdb>=2.0`

Note: Do not use a newer client to connect to an older server, as this may cause connection failures or unexpected errors.

You can get an example of using the package to read and write data at here:[Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/session_example.py)
You can get an example of using the package to read and write data at here:[Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/session_example.py)

An example of aligned timeseries: [Aligned Timeseries Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/session_aligned_timeseries_example.py)
An example of aligned timeseries: [Aligned Timeseries Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/session_aligned_timeseries_example.py)

(you need to add `import iotdb` in the head of the file)

Expand Down Expand Up @@ -194,9 +194,9 @@ def get_data():
ip, port_, username_, password_, use_ssl=use_ssl, ca_certs=ca_certs
)
session.open(False)
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("select * from root.eg.etth") as result:
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
session.close()
return df

Expand All @@ -217,9 +217,9 @@ def get_data2():
wait_timeout_in_ms = 3000
session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)
session = session_pool.get_session()
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("select * from root.eg.etth") as result:
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
session_pool.put_back(session)
session_pool.close()

Expand Down Expand Up @@ -547,11 +547,10 @@ username_ = "root"
password_ = "root"
session = Session(ip, port_, username_, password_)
session.open(False)
result = session.execute_query_statement("SELECT * FROM root.*")

# Transform to Pandas Dataset
df = result.todf()

with session.execute_query_statement("SELECT ** FROM root") as result:
# Transform to Pandas Dataset
df = result.todf()

session.close()

# Now you can work with the dataframe
Expand All @@ -571,8 +570,8 @@ class MyTestCase(unittest.TestCase):
with IoTDBContainer() as c:
session = Session("localhost", c.get_exposed_port(6667), "root", "root")
session.open(False)
result = session.execute_query_statement("SHOW TIMESERIES")
print(result)
with session.execute_query_statement("SHOW TIMESERIES") result:
print(result)
session.close()
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ First, download the package: `pip3 install apache-iotdb>=2.0`

Note: Do not use a newer client to connect to an older server, as this may cause connection failures or unexpected errors.

You can get an example of using the package to read and write data at here:[Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/session_example.py)
You can get an example of using the package to read and write data at here:[Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/session_example.py)

An example of aligned timeseries: [Aligned Timeseries Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/session_aligned_timeseries_example.py)
An example of aligned timeseries: [Aligned Timeseries Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/session_aligned_timeseries_example.py)

(you need to add `import iotdb` in the head of the file)

Expand Down Expand Up @@ -194,9 +194,9 @@ def get_data():
ip, port_, username_, password_, use_ssl=use_ssl, ca_certs=ca_certs
)
session.open(False)
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("select * from root.eg.etth") as result:
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
session.close()
return df

Expand All @@ -217,9 +217,9 @@ def get_data2():
wait_timeout_in_ms = 3000
session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)
session = session_pool.get_session()
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("select * from root.eg.etth") as result:
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
session_pool.put_back(session)
session_pool.close()

Expand Down Expand Up @@ -547,11 +547,10 @@ username_ = "root"
password_ = "TimechoDB@2021" //Before V2.0.6.x the default password is root
session = Session(ip, port_, username_, password_)
session.open(False)
result = session.execute_query_statement("SELECT * FROM root.*")

# Transform to Pandas Dataset
df = result.todf()

with session.execute_query_statement("SELECT ** FROM root") as result:
# Transform to Pandas Dataset
df = result.todf()

session.close()

# Now you can work with the dataframe
Expand All @@ -571,8 +570,8 @@ class MyTestCase(unittest.TestCase):
with IoTDBContainer() as c:
session = Session("localhost", c.get_exposed_port(6667), "root", "TimechoDB@2021") //Before V2.0.6.x the default password is root
session.open(False)
result = session.execute_query_statement("SHOW TIMESERIES")
print(result)
with session.execute_query_statement("SHOW TIMESERIES") result:
print(result)
session.close()
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,12 @@ def get_data():
ip, port_, username_, password_, use_ssl=use_ssl, ca_certs=ca_certs
)
session.open(False)
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("SHOW DATABASES") as session_data_set:
print(session_data_set.get_column_names())
while session_data_set.has_next():
print(session_data_set.next())

session.close()
return df


def get_data2():
Expand All @@ -361,9 +362,10 @@ def get_data2():
wait_timeout_in_ms = 3000
session_pool = SessionPool(pool_config, max_pool_size, wait_timeout_in_ms)
session = session_pool.get_session()
result = session.execute_query_statement("select * from root.eg.etth")
df = result.todf()
df.rename(columns={"Time": "date"}, inplace=True)
with session.execute_query_statement("SHOW DATABASES") as session_data_set:
print(session_data_set.get_column_names())
while session_data_set.has_next():
print(session_data_set.next())
session_pool.put_back(session)
session_pool.close()

Expand All @@ -374,9 +376,9 @@ if __name__ == "__main__":

## 4. Sample Code

**Session** Example: You can find the full example code at [Session Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/table_model_session_example.py).
**Session** Example: You can find the full example code at [Session Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/table_model_session_example.py).

**Session Pool** Example: You can find the full example code at [SessionPool Example](https://github.com/apache/iotdb/blob/rc/2.0.1/iotdb-client/client-py/table_model_session_pool_example.py).
**Session Pool** Example: You can find the full example code at [SessionPool Example](https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/table_model_session_pool_example.py).

Here is an excerpt of the sample code:

Expand Down Expand Up @@ -427,9 +429,9 @@ def prepare_data():

print("now the tables are:")
# show result
res = session.execute_query_statement("SHOW TABLES")
while res.has_next():
print(res.next())
with session.execute_query_statement("SHOW TABLES") as res:
while res.has_next():
print(res.next())

session.close()

Expand Down Expand Up @@ -484,14 +486,14 @@ def query_data():
session = session_pool.get_session()

print("get data from table0")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

print("get data from table1")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

session.close()

Expand All @@ -500,9 +502,9 @@ def delete_data():
session = session_pool.get_session()
session.execute_non_query_statement("drop database db1")
print("data has been deleted. now the databases are:")
res = session.execute_query_statement("show databases")
while res.has_next():
print(res.next())
with session.execute_query_statement("show databases") as res:
while res.has_next():
print(res.next())
session.close()


Expand Down
Loading
Loading