anxiousmodernman / teamdash

A platform for developing, scheduling, and viewing reports
0 stars 0 forks source link

Make the getMSSQLEngine() function smarter #10

Open anxiousmodernman opened 11 years ago

anxiousmodernman commented 11 years ago

This is in https://github.com/anxiousmodernman/teamdash/blob/master/datasource/engines.py

Right now it works like this:

from engines import getMSSQLEngine()

engine =  getMSSQLEngine()
conn = engine.connect()

result = conn.execute("select top 3 * from brief")
result_list = [item['brief_name'] for item in result]  # dope list comprehension, bro
print result_list

The SQLAlchemy engine takes a special connection string that specifies the driver and the SQL dialect (in our case MSSQL).

The function should take a parameter that lets us swap pymssql with pyodbc. Utlimately we should move towards pyodbc since it's better-supported, but if we have to we can fall back. Our code should default to pyodbc since you're developing on Linux and it's going to be a-ok if you use that.

I have the dbconfig.py file in my gitignore because it contains passwords and you should also do this. You'll have to make your own.