gpt4 book ai didi

python - SQLCLR 和 IronPython

转载 作者:太空宇宙 更新时间:2023-11-03 11:35:51 25 4
gpt4 key购买 nike

我感觉很疯狂,我决定我真的很想用 Python 编写一个可以在 SQL Server 2008 中运行的用户定义函数。我对此很感兴趣,因为我有几千行 PL/Python 函数为 PostgreSQL 编写,我很想知道我是否可以让该项目改为在 SQL Server 上运行。

我第一次看 IronPython 试图解决我是否可以转换像这样的 C#...

using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Function1()
{
// Put your code here
return new SqlString("Hello");
}
};

...进入 Python。

有人对此有任何想法吗?可能吗?

我特别困惑的一点是注释:

[Microsoft.SqlServer.Server.SqlFunction]

我如何用 Python 编写它?看起来有点像装饰器:)

欢迎所有建议。

干杯,汤姆

最佳答案

根据 this article你在浪费时间尝试。显然,即使在 UNSAFE 程序集中,您也不能在 SQL CLR 中使用动态语言。

关于python - SQLCLR 和 IronPython,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3503996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com