Skip to content

Instantly share code, notes, and snippets.

@josejaguirre josejaguirre/connect.py
Last active Sep 25, 2017

Embed
What would you like to do?
Cadena de conexión para Flask & SQL Alchemy
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
You can’t perform that action at this time.