要执行存储过程,我需要提供4个参数。
如何简单地修改此代码以调用存储过程并传递多个参数?
import pandas as pd
import pyodbc
DateFrom = 2
DateTo = 3
param3 = NULL
param4 = NULL
query = 'EXEC Test_procedure @DateFrom = {0}'.format(my_params) # How to modify it here to accept multiple?
conn = pyodbc.connect('DRIVER={SQL Server};server=MySrver;DATABASE=MyDatabase;Trusted_Connection=yes;')
df = pd.read_sql_query(query, conn, params= ) #??
df
答案 0 :(得分:1)
只需使用qmark扩展参数占位符即可:
require_once("../CRUD/php/db.php");
$conn = createDB();
if(isset($_POST['create']))
{
createData();
}
function createData()
{
$name = textboxValue("name_type");
$age = textboxValue("age_type");
$gender = textboxValue("gender_type");
$email = textboxValue("email_type");
$contact = textboxValue("contact_type");
$dept = textboxValue("dept_type");
$sql = "INSERT INTO details(name,age,gender,email,contact,department)
VALUES('$name', '$age', '$gender', $email', '$contact', '$dept');";
if(mysqli_query($GLOBALS['conn'],$sql))
{
echo "Data added";
}
else
{
echo "Error adding data";
}
}
function textboxValue($value)
{
$textbox = mysqli_real_escape_string($GLOBALS['conn'], trim($_POST[$value]));
if(empty($textbox))
{
return false;
}
else
{
return $textbox;
}
}