>>>import pyodbc
>>>cnxn = pyodbc.connect('DRIVER={SQL Server}SERVER=192.168.1.100\\sqlDATABASE=testDBUID=saPWD=myPassword')
>>>cursor = cnxn.cursor()
>>>cursor.execute("select * from Tb")
二、Linux下配置Python访问SqlServer
环境:CentOS 6.2 + Sqlserver 2008
1、安装freetds:
复制代码代码如下:
yum install freetds*
2、安装pyodbc:
复制代码代码如下:
yum install pyodbc
修改odbc配置:
复制代码代码如下:
vi /etc/odbcinst.ini
添加FreeTDS驱动:
复制代码代码如下:
[SQL Server]
Description = FreeTDS ODBC driver for MSSQL
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/libtdsS.so
FileUsage = 1
3、测试
复制代码代码如下:
#python
>>>import pyodbc
>>>cnxn = pyodbc.connect('DRIVER={SQL Server}SERVER=192.168.1.100\\sqlDATABASE=testDBUID=saPWD=myPassword')
>>>cursor = cnxn.cursor()
>>>cursor.execute("select * from Tb")
新手对于没有图形界面的linux远程登录及其 *** 作都充满畏惧。这里介绍一个简单的软件。叫作BitViz。简称BV for short。一、软件安装
这里使用Putty的一个client软件叫作Bv SshClient. 你可以在putty的官网上找到其链接。
Bitvise Tunnelier
Tunnelier is an SSH and SFTP client for Windows. It is developed and supported professionally by Bitvise. Tunnelier is robust, easy to install, easy to use, and supports all features supported by PuTTY, as well as the following:
graphical SFTP file transfer图形界面最喜欢
single-click Remote Desktop tunneling
auto-reconnecting capability
dynamic port forwarding through an integrated proxy
an FTP-to-SFTP protocol bridge. 方便的上传下载和删除 *** 作。
Tunnelier is free for personal use, as well as for individual commercial use inside organizations. You can download Tunnelier here. ownload-area
二、熟悉窗口
下面一个例子,是找到python软件安装位置的演示:
1. 首先,我进入到root
步骤一,进入root
2. 输入/home
步骤二,进入home
3. 点击其中子文件夹,即可找到,方便了。
步骤三,找到python文件夹
三、easy_install python library
Example Of python-setuptools Being Installed:
[root@server ~]# yum install python-setuptools
Yum Command To Install python-setuptools-devel:
[root@server ~]# yum install python-setuptools-devel
在linux 下: 使用方法非常简单,在命令行输入“easy_install 参数”即可。
这比我想象的要方便很多!在windows里,我要cmd-cd &easy_install flickrapi
在ssh的命令窗口,只需输入 easy_install flickrapi
如下图:
easy_install flickrapi
四、run python script as a background process in linux
So, you have a server to which you connect remotely, upload a python script and want to run it and logout from the server keeping the program running. If you frequently work with spiders, you surely want to do it. But how to do it? For example if your script's name is script.py, then the command is:
[root@server ~]# nohup python script.py &
And sometimes you may be interested to see the output is that being generated. Then you should view the nohup.out file! This command can be useful:
[root@server ~]# tail -f nohup.out
看看效果!
1.程序怎么判断你期望的系统是哪个?2.python可以实现自动登陆
3.难点在于,第一点
4.你准备使用什么技术实现?
5.机器学习?人脸检测?动作跟踪?and so on ?
6.希望可以帮助,请采纳,谢谢!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)