1. Baixe o Microsofy ODBC DRIVER 17 PARA SQL SERVER

https://docs.microsoft.com/pt-br/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

Ubuntu 14.04, 16.04, 17.10 e 18.04

Copiar

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Ubuntu 14.04
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.10
curl https://packages.microsoft.com/config/ubuntu/18.10/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

Instalando via pip o pyodbc

pip install pyodbc

Exemplo

import pyodbc
# Some other example server values are
# server = 'localhost\sqlexpress' # for a named instance
# server = 'myserver,port' # to specify an alternate port
server = 'server_dns,2127'
database = 'banco'
username = 'nome_do_usuario'
password = 'senha_do_usuario'
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()

cursor.execute("SELECT top 10* FROM tabela")
tables = cursor.fetchall()
for row in tables:
    print(row)
Este artigo foi útil ?
SimNão

11 Replies to “Pyodbc – conexao do Mssql Python via Pdo no Ubuntu”

  1. icgbetlogin disse:

    Need that ICG Bet login sorted out? It can be a pain sometimes! Hopefully, icgbetlogin makes it easy for you. Get in, place your bets, and have some fun!

  2. demopgslot disse:

    Demopgslot é top pra quem quer treinar antes de apostar de verdade! Dá pra testar os jogos sem gastar nada. Ótima dica pra iniciantes! demopgslot

  3. ta28bet disse:

    Ta28bet is where it’s at! Good odds, and easy to place bets. Been having some good luck lately. Jump in on the action: ta28bet

  4. up786game disse:

    Yo, up786game is kinda cool! The graphics are better than I expected, and I appreciate the various options they offer. It’s not perfect, but it’s solid. Check it out for yourself here: up786game.

  5. bonos777bet disse:

    Been checking out bonos777bet lately, mainly for the bonuses. They’re pretty good, definitely worth keeping an eye on. Check it: bonos777bet

  6. Been looking for the safest place to grab the latest 188bet app. Found 188betappdownload. Has anybody used this site before? Tell me your experiences or go check them out at 188betappdownload.

  7. 200jilicasino disse:

    The bonuses here are actually legit! I managed to hit a decent streak last night. It feels way more fair than other platforms I have tried. Visit 200jilicasino

  8. krwinclub88 disse:

    Joined the club and the rewards are actually insane. It’s great to see a platform that actually cares about its players. Join krwinclub88 and see for yourself.

  9. brafunvip disse:

    The bonuses here are legit and not just bait. I had a great experience with the registration process. Give brafunvip a shot if you are looking for some real action.

  10. pk365lucky disse:

    Really honest platform with fair odds. I appreciate how transparent everything is here. Good luck to everyone playing! pk365lucky

  11. luky55game disse:

    Just hit a decent win here and the withdrawal was processed faster than I expected. The variety of games is impressive. Give luky55game a shot if you want a fair platform.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Close Search Window
↑