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 16
16
# https://hub.docker.com/_/python
17
17
FROM python:3.9-buster
18
18
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
-
24
19
# Copy application dependency manifests to the container image.
25
20
# Copying this separately prevents re-running pip install on every code change.
26
21
COPY requirements.txt ./
Original file line number Diff line number Diff line change 25
25
26
26
3 . Click ** CREATE** .
27
27
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
+
29
29
30
30
1 . Create a service account with the 'Cloud SQL Client' permissions by following these
31
31
[ 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.
1
14
from contextlib import contextmanager
2
15
import logging
3
16
import os
4
17
from typing import Dict
5
18
6
- import pyodbc
19
+ import pytds
7
20
import pytest
8
21
9
22
import main
@@ -45,7 +58,7 @@ def tcp_db_connection():
45
58
def _common_setup ():
46
59
try :
47
60
pool = main .init_connection_engine ()
48
- except pyodbc .OperationalError as e :
61
+ except pytds .OperationalError as e :
49
62
logger .warning (
50
63
'Could not connect to the production database. '
51
64
'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):
92
92
# managing a pool of connections to your database
93
93
pool = sqlalchemy .create_engine (
94
94
# 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
96
96
sqlalchemy .engine .url .URL (
97
- "mssql+pyodbc " ,
97
+ "mssql+pytds " ,
98
98
username = db_user ,
99
99
password = db_pass ,
100
100
database = db_name ,
101
101
host = db_hostname ,
102
102
port = db_port ,
103
- query = {"driver" : "ODBC Driver 17 for SQL Server" },
104
103
),
105
104
** db_config
106
105
)
Original file line number Diff line number Diff line change 1
1
Flask == 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
+
4
7
You can’t perform that action at this time.
0 commit comments