SQLCLR&铁蟒
我感觉很疯狂,我决定我真的很想用 Python 编写一个可以在 SQL Server 2008 中运行的用户定义函数。我对此很感兴趣,因为我有几千行为 PostgreSQL 编写的 PL/Python 函数我很想知道是否可以让该项目在 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]
How do I write that in Python?看起来有点像装饰器:)
欢迎所有建议。
干杯, 汤姆
Im feeling crazy and I've decided I would really like to write a User-Defined Function in Python that would run in SQL Server 2008. I am interested in doing this as I have a few thousand lines of PL/Python functions written for PostgreSQL and I am interested to know if I can get the project running on SQL Server instead.
I am looking at IronPython for the first time trying to work out if I can convert something like this 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");
}
};
... into Python.
Has anyone got any ideas on this one? Is it possible?
The bit I am particularly perplexed by is the annotation:
[Microsoft.SqlServer.Server.SqlFunction]
How do I write that in Python? Looks a bit like a decorator :)
All suggestions welcome.
Cheers,
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这篇文章 你这是在浪费时间。显然,即使在 UNSAFE 程序集中,您也无法在 SQL CLR 中使用动态语言。
According to this article you're wasting your time trying. Apparently you simply can't use dynamic languages in SQL CLR even in UNSAFE assemblies.