用python或ironpython访问mssql的最简单方法是什么? [英] What's the simplest way to access mssql with python or ironpython?

查看:70
本文介绍了用python或ironpython访问mssql的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的个人计算机上运行了mssql 2005,并且我想在上面运行一些python脚本的数据库.我正在寻找一种对数据进行一些非常简单的访问的方法.我想运行一些select语句,处理数据,也许让python用结果保存文本文件.

I've got mssql 2005 running on my personal computer with a database I'd like to run some python scripts on. I'm looking for a way to do some really simple access on the data. I'd like to run some select statements, process the data and maybe have python save a text file with the results.

不幸的是,即使我对python有点了解,对数据库也有点了解,但是我很难从阅读中分辨出库是否满足我的要求.理想情况下,我想要一种适用于其他版本的mssql的东西,它是免费的,并获得许可以允许商业使用,使用简单,并且可能与ironpython一起使用.

Unfortunately, even though I know a bit about python and a bit about databases, it's very difficult for me to tell, just from reading, if a library does what I want. Ideally, I'd like something that works for other versions of mssql, is free of charge and licensed to allow commercial use, is simple to use, and possibly works with ironpython.

推荐答案

我在cPython中使用 SQL炼金术(我不知道它是否可以与IronPython一起使用).如果您使用过Hibernate/nHibernate,这将对您非常熟悉.如果这对您来说太冗长,您可以使用 Elixir ,这是最薄的一层SQL炼金术.要使用其中任何一个,您都需要 pyodbc ,但这是一个非常简单的安装.

I use SQL Alchemy with cPython (I don't know if it'll work with IronPython though). It'll be pretty familiar to you if you've used Hibernate/nHibernate. If that's a bit too verbose for you, you can use Elixir, which is a thin layer on top of SQL Alchemy. To use either one of those, you'll need pyodbc, but that's a pretty simple install.

当然,如果您想直接编写SQL而不使用ORM,则只需要pyodbc.

Of course, if you want to write straight SQL and not use an ORM, you just need pyodbc.

这篇关于用python或ironpython访问mssql的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆