Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
reset-bandwidth-monthly-py
import MySQLdb
import os
import sys
from sqlalchemy import create_engine, MetaData
from sqlalchemy.sql import text
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import Column, String, Integer, Date, Table, ForeignKey, Float
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from urllib import quote_plus as urlquote
from multiprocessing.dummy import Pool as ThreadPool
import json
import urllib
import smtplib
from email.mime.text import MIMEText
import requests
import paramiko
import time
from config import *
import boto3
from models import Subscription, Server
# Setup SQLAlchemy
engine = create_engine('mysql://ghostifidbuser:%s@localhost:3306/ghostifi' % urlquote(DB_PASSWORD), echo=False)
metadata = MetaData(bind=engine)
Session = scoped_session(sessionmaker(engine, autoflush=True))
session = Session()
Base = declarative_base()
Base.metadata.create_all(engine)
# Get all server object
all_servers = session.query(Server).all()
for server in all_servers:
print server.server_name
server.bandwidth_this_month = 0
session.commit()
session.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment