GPG: конфликтующие команды с Ubuntu Buster Container - PullRequest
0 голосов
/ 04 ноября 2019
root@324c911bba2f:/# curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: apt-key output should not be parsed (stdout is not a terminal)
100   983  100   983    0     0   5173      0 --:--:-- --:--:-- --:--:--  5146
gpg: conflicting commands

Я попытался установить MS ODBC Driver на мой Ubuntu Container с VS Code. К сожалению, я не могу установить драйвер после установки руководства от г-жи. Детали изображения:

    System:    Host: 324c911bba2f Kernel: 4.9.184-linuxkit x86_64 bits: 64 Console: tty 0 Distro: Debian GNU/Linux 10 (buster)
Machine:   Type: Desktop Mobo: Microsoft model: Virtual Machine v: Hyper-V UEFI Release v4.0
           serial: 1535-8066-3525-8144-3146-6191-62 BIOS: Microsoft v: Hyper-V UEFI Release v4.0 date: 08/31/2018
CPU:       Topology: Dual Core model: Intel Core i7-6820HQ bits: 64 type: MCP L2 cache: 8192 KiB
           Speed: 2718 MHz min/max: N/A Core speeds (MHz): 1: 2718 2: 2718
Graphics:  Message: No Device data found.
           Display: server: No display server data found. Headless machine? tty: 229x23
           Message: Advanced graphics data unavailable in console for root.
Audio:     Message: No Device data found.
Network:   Message: No Device data found.
           IF-ID-1: eth0 state: up speed: 10000 Mbps duplex: full mac: 02:42:ac:11:00:02
           IF-ID-2: ip6tnl0 state: down mac: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
           IF-ID-3: tunl0 state: down mac: 00:00:00:00
Drives:    Local Storage: total: 59.60 GiB used: 4.97 GiB (8.3%)
           ID-1: /dev/sda model: Virtual Disk size: 59.60 GiB
Partition: ID-1: / size: 58.42 GiB used: 2.48 GiB (4.2%) fs: overlay source: ERR-102
Sensors:   Message: No sensors data was found. Is sensors configured?
Info:      Processes: 3 Uptime: 4h 38m Memory: 2.67 GiB used: 581.0 MiB (21.3%) Init: N/A Shell: bash inxi: 3.0.32

Если я попытался сначала установить pyodbc, я также получил ошибку.

 Building wheel for pyodbc (setup.py): started
  Building wheel for pyodbc (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-k5va9x0c/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-k5va9x0c/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-y2_vqoa_ --python-tag cp38
       cwd: /tmp/pip-install-k5va9x0c/pyodbc/
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.27 -I/usr/local/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-3.8/src/buffer.o -Wno-write-strings
  In file included from src/buffer.cpp:12:
  src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
   #include <sql.h>
            ^~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------

Так что, вероятно, я использую совершенно неправильный обходной путь для установки драйвера ODBC. Мой план состоит в том, чтобы соединить мой контейнер Python с моей базой данных Ms Sql на хост-клиенте. Поэтому я использую строку подключения DSN в своем коде.

  connection = Library.Scribts.OwnStdLib.GetConfigNetwork()

cnxn = pyodbc.connect('DSN=' + connection["DSN"]  + ';UID=' + connection["UID"] + ';PWD=' + connection["password"])
cursor = cnxn.cursor()

Я благодарен за любые идеи или комментарии. Best NOert

1 Ответ

0 голосов
/ 05 ноября 2019

Так что я рад получить решение для моего выпуска. Прежде всего, я получаю новый способ.

Мой Dockerfile: ОТ python: 3.8.0-buster RUN apt-get update RUN apt-get -y install freetds-dev freetds-bin unixodbc-dev tdsodbc

COPY ./requirements.txt /requirements.txt
COPY ./odbcinst.ini /etc/odbcinst.ini


WORKDIR /

RUN pip3 install -r requirements.txt

COPY . / 

Мой odbcinst.ini в корневом каталоге

[ODBC Driver 17 for SQL Server]
Description=ODBC Driver 17 for SQL Server
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so

Мой код, где я использую Соединение.

https://gist.github.com/rduplain/1293636

...