There is an issue when using chatglm to call the TiDB database through langchain, but it works fine when switched to MySQL

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 使用chatglm 通过langchain调用tidb数据库时有问题改成mysql就好了

| username: TiDBer_kn6fnmHR

The specific error is sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 12 near “请求模型” ')
[SQL: 请求模型]

| username: tidb菜鸟一只 | Original post link

What are the character sets of the two databases?

| username: MrSylar | Original post link

Check the code for the SQL statement that caused the error, then run it in TiDB to see where it is incompatible with MySQL.

| username: 小龙虾爱大龙虾 | Original post link

Go to the dashboard’s log search and search for the keyword “command dispatched failed”. You can find the SQL that caused the error.

| username: dba远航 | Original post link

The issue of syntax support

| username: TiDBer_kn6fnmHR | Original post link

It should be a database encoding issue. There is no problem when switching to other databases. This database has not set the character set encoding.

| username: TiDBer_kn6fnmHR | Original post link

I am using sqldatabasechain for interaction here, and it is not associated with specific SQL statements.

| username: TiDBer_kn6fnmHR | Original post link

Boss, TiDB and Flink always show this error, but it gets better after a while. Which TiDB configuration might be the problem?

| username: 有猫万事足 | Original post link

You have no problem asking about other middleware here in TiDB.
At least provide the version information of flink-cdc-connectors.
At the very least, it seems that it is no longer written this way.

| username: TiDBer_kn6fnmHR | Original post link

Using TiDB 7.3, Flink 1.17, flink-sql-connector-tidb-cdc 2.2.1. If CDC uses a version later than 2.2.1, the CPU will always be highly utilized.

| username: 有猫万事足 | Original post link

When fetching the tableId, a null pointer exception occurred.

Currently, it’s unclear which position has the null pointer.

Are there any other exceptions in the error stack?

Looking at it now, TiSession will check whether this session has been closed.

Could it be a session expiration issue?

| username: TiDBer_kn6fnmHR | Original post link

This situation always fails directly during initialization.

| username: 有猫万事足 | Original post link

Also, could it be that your table is a view?

  // TODO: support reading from view table in the future.

I see a comment here saying that views are not supported.