Last active
December 16, 2015 07:19
-
-
Save maltzsama/5397907 to your computer and use it in GitHub Desktop.
SqlServer from python with pymssql using Debian or Arch Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #Packages | |
| #python, freetds e pymssql | |
| distro=$(lsb_release -a | grep "Distributor ID:") | |
| if [ ${distro:16:6} = "Debian" ]; then | |
| #Install Debian packages | |
| echo "Debian" | |
| apt-get install python freetds-common | |
| apt-get install python-pymssql | |
| elif [ ${distro:16:4} = "arch" ]; then | |
| #Install Arch Linux packages | |
| echo "Arch linux" | |
| pacman -S python freetds | |
| wget -c http://aur.archlinux.org/packages/pymssql/pymssql.tar.gz | |
| tar -xvvzf pymssql.tar.gz | |
| cd pymssql | |
| makepkg PKGBUILD | |
| pacman -U pymssql-0.8.0-1.pkg.tar.gz | |
| else | |
| echo "Distro not supported" | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import pymssql | |
| conn=pymssql.connect(host='DBSERVER', user='USER', password='PASS', database='DBTESTE') | |
| cur=conn.cursor() | |
| cur.execute("SELECT GETDATE()") | |
| date=cur.fetchone() | |
| print date | |
| conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment