This project uses Kenneth Reitz's Records
library in addition to PyODBC to connect to the lansweeperdb Microsoft SQL Server database.
Records makes it easier to export results of SQL queries and make it easier to
explore the database to learn its schema. It uses docopt
to handle argument parsing
so you can use it as a command-line application, or launch a Flask web interface.
- Install Python 3.x with pip.
- Install Microsoft ODBC Driver 11 for SQL Server which you may already have in Windows, but typically not in other systems.
- If you're in Windows, open up the Data Sources program. If you're in Linux, edit the ~/.odbc.ini file in the next step.
- Create a DSN (Data Source Name) called
PSI-SQL-DSN
that connects to thePSI-SQL
server, defaulting to thelansweeperdb
database and use SQL authentication. - Update the
server
variable to match the name of the DSN if you chose something other thanPSI-SQL-DSN
. - Create and activate a virtual environment
- Install dependencies:
pip install -r requirements.txt
- Profit!
All you have to do is run lansweeper_all.py
and enter the number for the
report type you want when asked for it. For example, if you want to see a
table for Administrative / Business Development tickets, activate your virtual
environment and then run python lansweeper_all.py
at which point it will
list out the different options. Enter 0 and hit enter. The resulting table
will be placedin a .xlsx file in the Reports folder called admin_bus_dev.xlsx
.
Launch the Flask web app by running python run.py
and visit the application
in your web browser at localhost:5000
. From there you can click on the report
type you would like.