Example #1
0
A wrapper around common objects in Petra db 
Copyright (C) 2012 Petra Trust
( http://www.petratrust.com )

"""

import re
import pyodbc
import datetime
import httplib2
import PySQLObject as psql

# Connect to MSSQL and MySQL databases
conn = pyodbc.connect("DSN=odbc-petra")
cursor = conn.cursor()
petra_db = psql.db(host="mysql.petratrust.com", user="******", passwd="sh0wm3th3m0n3y", db="petramembersdb")

http = httplib2.Http()

class Deal:
   "Store a deal"

   def __init__(self, row):
       self.did,self.dtype,self.fid,self.cid,self.ddate,self.dunits,self.dprice,self.dpayment, self.cancelid = row
       if self.cancelid is None:
	       self.cancelid = 0

   def tosql(self):
       return "("+str(self.did)+",'"+self.dtype+"','"+str(self.fid)+"','"+str(self.cid)+"','"+str(self.ddate)+"','"+str(self.dunits)+"','"+str(self.dprice)+"','"+str(self.dpayment)+"','"+str(self.cancelid)+"'),"

Example #2
0
Copyright (C) 2012 Petra Trust
( http://www.petratrust.com )

"""

import re
import datetime
import httplib2
import PySQLObject as psql

import time
import sys

# Connect to MSSQL and MySQL databases
petra_db = psql.db(host="localhost",
                   user="******",
                   passwd="",
                   db="petramembersdb")
http = httplib2.Http()


def CallBalanceApi(client_id):
    url = 'http://localhost/members/api/balance_history?params[id]=' + str(
        client_id)
    response, content = http.request(url)
    return content


def MYSQLQuery(sql, table=None):
    regex = re.compile(',$')
    sql = regex.sub('', sql)
Example #3
0
A wrapper around common objects in Petra db 
Copyright (C) 2012 Petra Trust
( http://www.petratrust.com )

"""

import re
import datetime
import httplib2
import PySQLObject as psql

import time
import sys

# Connect to MSSQL and MySQL databases
petra_db = psql.db(host="localhost", user="******", passwd="", db="petramembersdb")
http = httplib2.Http()

def CallBalanceApi(client_id):
    url = 'http://localhost/members/api/balance_history?params[id]='+str(client_id)
    response, content = http.request(url)
    return content
    
def MYSQLQuery(sql, table=None):
    regex = re.compile(',$')
    sql = regex.sub('', sql)

    if table:
       petra_db.query("TRUNCATE TABLE `"+table+"`")
    a = petra_db.query(sql)
    petra_db.commit()
Example #4
0
A wrapper around common objects in Petra db 
Copyright (C) 2012 Petra Trust
( http://www.petratrust.com )

"""

import re
import datetime
import httplib2
import PySQLObject as psql

import time
import sys

# Connect to MSSQL and MySQL databases
petra_db = psql.db(host="mysql.petratrust.com", user="******", passwd="sh0wm3th3m0n3y", db="petramembersdb")
http = httplib2.Http()

def CallBalanceApi(client_id):
    url = 'http://www.petratrust.com/members/api/getbh?params[id]='+str(client_id)
    response, content = http.request(url)
    return content
    
def MYSQLQuery(sql, table=None):
    regex = re.compile(',$')
    sql = regex.sub('', sql)

    if table:
       petra_db.query("TRUNCATE TABLE `"+table+"`")
    a = petra_db.query(sql)
    petra_db.commit()