File tree Expand file tree Collapse file tree 5 files changed +23
-13
lines changed
cloud-sql/sql-server/sqlalchemy Expand file tree Collapse file tree 5 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 1616# https://hub.docker.com/_/python
1717FROM python:3.9-buster
1818
19- # Download the desired package(s) for Microsoft ODBC 17 Driver
20- RUN (curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -) && \
21- curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
22- apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev
23-
2419# Copy application dependency manifests to the container image.
2520# Copying this separately prevents re-running pip install on every code change.
2621COPY requirements.txt ./
Original file line number Diff line number Diff line change 2525
2626 3 . Click ** CREATE** .
2727
28- 1 . Install the version of [ Microsoft ODBC 17 Driver for SQL Server ] ( https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver15_ ) for your operating system.
28+
2929
30301 . Create a service account with the 'Cloud SQL Client' permissions by following these
3131[ instructions] ( https://cloud.google.com/sql/docs/postgres/connect-external-app#4_if_required_by_your_authentication_method_create_a_service_account ) .
Original file line number Diff line number Diff line change 1+ # Copyright 2020 Google LLC
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
114from contextlib import contextmanager
215import logging
316import os
417from typing import Dict
518
6- import pyodbc
19+ import pytds
720import pytest
821
922import main
@@ -45,7 +58,7 @@ def tcp_db_connection():
4558def _common_setup ():
4659 try :
4760 pool = main .init_connection_engine ()
48- except pyodbc .OperationalError as e :
61+ except pytds .OperationalError as e :
4962 logger .warning (
5063 'Could not connect to the production database. '
5164 'If running tests locally, is the cloud_sql_proxy currently running?'
Original file line number Diff line number Diff line change @@ -92,15 +92,14 @@ def init_tcp_connection_engine(db_config):
9292 # managing a pool of connections to your database
9393 pool = sqlalchemy .create_engine (
9494 # Equivalent URL:
95- # mssql+pyodbc ://<db_user>:<db_pass>@/<host>:<port>/<db_name>?driver=ODBC+Driver+17+for+SQL+Server
95+ # mssql+pytds ://<db_user>:<db_pass>@/<host>:<port>/<db_name>?driver=ODBC+Driver+17+for+SQL+Server
9696 sqlalchemy .engine .url .URL (
97- "mssql+pyodbc " ,
97+ "mssql+pytds " ,
9898 username = db_user ,
9999 password = db_pass ,
100100 database = db_name ,
101101 host = db_hostname ,
102102 port = db_port ,
103- query = {"driver" : "ODBC Driver 17 for SQL Server" },
104103 ),
105104 ** db_config
106105 )
Original file line number Diff line number Diff line change 11Flask == 1.1.2
2- SQLAlchemy == 1.3.23
3- pyodbc == 4.0.30
2+ SQLAlchemy == 1.3.22
3+ python-tds == 1.10.0
4+ sqlalchemy-pytds == 0.3.1
5+ pyopenssl == 20.0.1
6+
47
You can’t perform that action at this time.
0 commit comments