- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我试图在 sql 查询中传递三个变量。这些是地区、功能、新用户。我正在使用 SQL 驱动程序 SQL Server Native Client 11.0。
这是我的有效代码。
query = "SELECT LicenseNo FROM License_Mgmt_Reporting.dbo.MATLAB_NNU_OPTIONS WHERE Region = ?"
data_df = pd.read_sql_query((query),engine,params={region})
输出。
LicenseNo
0 12
1 5
相反,我想传入三个变量,但这段代码不起作用。
query = "SELECT LicenseNo FROM License_Mgmt_Reporting.dbo.MATLAB_NNU_OPTIONS WHERE Region = ? and FeatureName = ? and NewUser =?"
nnu_data_df = pd.read_sql_query((query),engine,params={region, feature, newUser})
输出返回一个空数据框。
Empty DataFrame
Columns: [LicenseNo]
Index: []
最佳答案
尝试一个元组中的字符串,也可以去掉查询中的():
所以你可以做类似的事情
query = "SELECT LicenseNo FROM License_Mgmt_Reporting.dbo.MATLAB_NNU_OPTIONS WHERE Region = ? and FeatureName = ? and NewUser =?"
region = 'US'
feature = 'tall'
newUser = 'john'
data_df = pd.read_sql_query(query, engine, params=(region, feature , newUser))
关于python - 如何使用 pandas pd.read_sql_query 使用多个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40180884/
刚刚开始学习 Pandas 并偶然发现了“read_sql_query”: 在我的代码中有多个创建语句,并使用“read_sql_query”执行它们会使作业变得多余,例如: import panda
是否可以使用炼金术 session (https://stackoverflow.com/a/33648514)调用 pandas.read_sql_query?示例: with db_session
我正在使用 pandas.read_sql_query 从 Sql 服务器读取一些数据。我读取的数据类型是Sql server中的int和real,即32位整数和32位浮点值。但在生成的数据框中,数据
当我这样做 from sqlalchemy import create_engine import pandas as pd engine = create_engine('sqlite://') c
我有一个封闭的连接: Config = dict(server = serverSample, port = 1433, username =
问题 我可以使用 read_sql() 将 SQL 事务提交到数据库吗? 用例和背景 我有一个用例,我希望允许用户执行一些预定义的 SQL 并返回一个 Pandas 数据帧。在某些情况下,此 SQL
我正在使用 Python(Jupyter Notebook)和 Postgres 数据库,并且正在努力填充 Pandas 数据框。 sql 代码使用 pgAdmin4 中的查询生成器运行良好 SELE
我正在尝试在 python pandas 中组合一个 SQL 查询。我尝试了不同的方法,但总是出现以下错误:提供的绑定(bind)数量不正确。当前语句使用 6 个,提供了 3 个。 我的代码如下。我做
我有两个表:trainSearcStream 和 SearchInfo。我的代码应该根据名为 SearchID 的公共(public)列合并这两个表。问题是代码运行了一段时间然后终止而没有在我的 ec
我正在使用 pandas read_sql_query 将数据从 MySQL 数据库表读取到 pandas 数据帧中。此表中的某些列全部为 NULL 值。对于这些列, Pandas 数据框的每一行都包
我有以下行 df = pandas.read_sql_query(sql = sql_script, con=conn, coerce_float = False) 使用 sql 脚本从 Postgr
我想使用类似于 pandas“read_sql_query”的东西,将数据库中的数据加载到 numpy 数组中,而不是 pandas 数据帧中。 在 pandas 中我使用类似的东西: df = pd
我有一个带有字符串类型列的 df,单元格可能是空字符串“”(中间没有空格)。我想将 df 写入 mysql,如下所示: df.to_sql(name, conn) 然后我想查询 df 并过滤掉带有空字
从 MySQL 数据库检索数据时,Pandas parse_date 应该如何工作? Pandas 0.23 的文档提供此信息: parse_dates : list or dict, default
我有一个包含以下列的表格: | Date | ProductId | SubProductId | Value | 我正在尝试从该表中检索数据并将其放入 pandas DataFrame 中。 我希望
在处理数据库 decimal 数据类型时,我遇到了 Pandas read_sql_query() 函数的问题。在使用 varchar 或 integer 类型时,我对下面相同的代码没有任何问题。 版
我试图在 sql 查询中传递三个变量。这些是地区、功能、新用户。我正在使用 SQL 驱动程序 SQL Server Native Client 11.0。 这是我的有效代码。 query = "SEL
我想执行一个操作,我想删除 postgres 中的所有行(但不删除表)并更新其中的新行。我想使用 pandas 的 pd.read_sql_query() 方法: qry = 'delete from
我一直在尝试测试使我的代码运行的各种方法。首先,我有这个列表: member_list = [111,222,333,444,555,...] 我试图将它传递到这个查询中: query = pd.re
我正在使用 pandas.read_sql_query 函数读取一些 sql 文件。一个查询在我挑出的某一特定位处抛出错误。 (python 位 - 没有什么奇怪的并且可以与其他查询一起使用) @co
我是一名优秀的程序员,十分优秀!