Last active
September 25, 2017 13:11
-
-
Save josejaguirre/8cafd8818eea2659e3e9c250a3344128 to your computer and use it in GitHub Desktop.
Cadena de conexión para Flask & SQL Alchemy
This file contains 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
import urllib | |
import pyodbc | |
from flask import Flask, request, jsonify | |
from flask_sqlalchemy import SQLAlchemy | |
app = Flask(__name__) | |
# Cadena de conexión | |
string_connection = "DRIVER={SQL Server};Database=DATABASE_NAME;SERVER=SERVER_NAME;UID=USER;PWD=PASSWORD" | |
string_connection = urllib.parse.quote_plus(string_connection) | |
string_connection = "mssql+pyodbc:///?odbc_connect=%s" % string_connection | |
app.config["SQLALCHEMY_DATABASE_URI"] = string_connection | |
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True | |
db = SQLAlchemy(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment