rename scr to src
This commit is contained in:
parent
0d0e49d684
commit
b375bf096f
9 changed files with 0 additions and 0 deletions
|
|
@ -1,43 +0,0 @@
|
|||
'''
|
||||
Created on 26.11.2013
|
||||
|
||||
@author: rauchp
|
||||
'''
|
||||
|
||||
from MySQLdb import connect
|
||||
|
||||
def setup(conf):
|
||||
connection = connect(host = conf['mySQL_server'],
|
||||
user = conf['mySQL_user'],
|
||||
passwd = conf['mySQL_pass'],
|
||||
db = conf['mySQL_database'],
|
||||
port = int(conf['mySQL_port']))
|
||||
cursor = connection.cursor()
|
||||
return cursor
|
||||
|
||||
def loop(cursor, item):
|
||||
sql_values = 'SELECT * FROM %s ORDER BY timestamp DESC LIMIT 1'
|
||||
sql_collums = 'SHOW COLUMNS FROM %s'
|
||||
|
||||
path = item.split('/')
|
||||
if path[0] == '':
|
||||
path.remove('')
|
||||
|
||||
collums = []
|
||||
cursor.execute(sql_collums % path[len(path) -1])
|
||||
for cul in cursor:
|
||||
collums.append(cul[0])
|
||||
|
||||
cursor.execute(sql_values % path[len(path) -1])
|
||||
for row in cursor:
|
||||
values = row
|
||||
|
||||
result = {}
|
||||
for i in range(len(collums)):
|
||||
result[collums[i]] = values[i]
|
||||
|
||||
# for p in range(len(path)):
|
||||
# result = { path.pop() : result }
|
||||
result = {item : result}
|
||||
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue