python connector: error.ProgrammingError: login disconnected, login again
I managed to use following code (revised on the example included in the TDengine Windows (1.8M) package) to connect my db.
conn = taos.connect(host="192.168.0.1", user="root", password="taosdata", config="/etc/taos")
c1 = conn.cursor()
And got following prompt which seems to work.
07/29 16:37:00.676000 0x2931601042736 TSC set config file directory:/etc/taos
connect to TDengine success
option file:/etc/taos/taos.cfg not found, all options are set to system default
But once I tried more than that, like
conn = taos.connect(host="192.168.0.1", user="root", password="taosdata", config="/etc/taos")
# Generate a cursor object to run SQL commands
c1 = conn.cursor()
# Create a database named db_demo
try:
c1.execute('create database db_demo')
except Exception as err:
conn.close()
raise(err)
# use database
try:
c1.execute('use db_demo')
except Exception as err:
conn.close()
raise(err)
I got an error.
07/29 16:41:29.489000 0x2280958577136 TSC set config file directory:/etc/taos
connect to TDengine success
connection is closed
Traceback (most recent call last):
File "E:/GitHub/tdengine_playground/read_example.py", line 44, in <module>
raise(err)
File "E:/GitHub/tdengine_playground/read_example.py", line 41, in <module>
c1.execute('use db_demo')
File "E:\GitHub\tdengine_playground\tdengine_python3\cursor.py", line 113, in execute
raise ProgrammingError(CTaosInterface.errStr(self._connection._conn))
tdengine_python3.error.ProgrammingError: login disconnected, login again
option file:/etc/taos/taos.cfg not found, all options are set to system default
Please advise how to fix it. P.S. I was using windows client DLL driver and python 3.7 on Win10. Thanks.
there is some bug in the python connector on windows, we will fixed soon
we have already submit the python connector in windows platform
Just tried the new one. But the problem still persists. Please have a look at my original question again. BTW, I got following exception when executing the new code.
Traceback (most recent call last):
File "E:/GitHub/tdengine_playground/read_example.py", line 37, in <module>
raise(err)
File "E:/GitHub/tdengine_playground/read_example.py", line 34, in <module>
c1.execute('create database db_demo2')
File "E:\GitHub\tdengine_playground\tdengine_python3\cursor.py", line 105, in execute
res = CTaosInterface.query(self._connection._conn, stmt)
File "E:\GitHub\tdengine_playground\tdengine_python3\cinterface.py", line 247, in query
CTaosInterface.libtaos.close(connection)
File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 369, in __getattr__
func = self.__getitem__(name)
File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 374, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'close' not found
The function should be 'taos_close' instead of 'close'. Please double check it. Thanks.
There is a bug in the CTaosInterface.libtaos.close(connection) function. We have solved it and uploaded the new driver. Could you pull it from GitHub and try it again? It is in the folder "src/connector/python/windows/python3".