DatabaseError: Execution failed on sql 'SELECT trade_date, net_mf_amount FROM `table_0` ORDER BY trade_date DESC': 1146 (42S02): Table 'daily.table_0' doesn't exist
时间: 2024-02-09 12:11:36 浏览: 141
这个错误提示表明你尝试查询的 `table_0` 表格不存在于 `daily` 数据库中。
请确保表格名称和数据库名称都正确,并且这个表格确实存在于数据库中。你可以在 MySQL 命令行界面或者其他工具中验证这些信息。
另外,如果表格名称中包含特殊字符,需要使用反引号将其括起来。你可以尝试使用以下语句查询表格:
```python
query = f"SELECT trade_date, net_mf_amount FROM `table_0` ORDER BY trade_date DESC"
```
如果还有问题,请提供更多信息,我会尽力帮助你解决问题。
相关问题
pandas.errors.DatabaseError: Execution failed on sql 'select * from drug;': no such table: drug
这个错误通常表示在执行 SQL 查询时找不到名为 "drug" 的表。请确保你的数据库中存在名为 "drug" 的表,并且拼写和大小写都正确。如果你确定表存在且拼写正确,可能是连接的数据库不正确或者没有权限访问该表。请检查连接数据库的配置和用户权限。如果问题仍然存在,请提供更多的信息,以便我可以更好地帮助你解决问题。
还是报错DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': ORA-01036: 非法的变量名/编号
这个错误消息表明,你正在使用 SQLite 特有的 SQL 语句,而不是 Oracle 数据库支持的 SQL 语句。为了解决这个问题,你需要将查询语句修改为 Oracle 数据库支持的语法。
下面是一个示例代码,可以将 DataFrame 写入 Oracle 数据库中:
```python
import pandas as pd
import cx_Oracle
# 建立 Oracle 数据库连接
conn = cx_Oracle.connect('username/password@host:port/service_name')
# 读取 Excel 文件
df = pd.read_excel('your_excel_file.xlsx')
# 将数据写入 Oracle 数据库
table_name = 'your_table_name'
df.to_sql(table_name, conn, if_exists='replace', index=False)
# 查询数据
cursor = conn.cursor()
cursor.execute(f"SELECT * FROM {table_name}")
result = cursor.fetchall()
# 打印结果
print(result)
# 关闭数据库连接
cursor.close()
conn.close()
```
在上面的代码中,你需要将用户名、密码、主机、端口和服务名替换为你的 Oracle 数据库的实际值。你还需要将 Excel 文件名和表名替换为你的实际值。
如果你仍然遇到问题,请提供具体的错误消息和代码,以便我更好地帮助你解决问题。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)