Upcoming Features in MonitorES !

Hello All,

I am planning to release the next version of MonitorES in next couple of weeks. These are the features that will be available in that version.

  • Completely re-written from scratch.
  • Windows 7 Support – Mute, Control Power Scheme’s.
  • More Media Players and Instant Messenger’s.
  • Custom Hot-Key’s
  • Improved Display Status control ( Monitor – auto check status in given interval )
  • Improved Screen Saver control.
  • Compatible with Windows XP/Vista/7 (32/64 bit)
  • Portable and 50 KB in size !
  • New Logo and Even New Name(Yes, It’s getting a new and more appropriate name!)
  • And lot of other cool new features…  !!! Seriously :)

So , Count down starts … ;)

Connect Oracle DB from Python

Simple steps to connect to oracle database from windows operating system.

Requirements:

To connect to oracle we need either oracle client installed on your local machine or instant client from oracle ( recommended , if you don’t have oracle client)

Get the proper version of Python and cxOracle versions ( I’ve used Python 2.6.4 with cxOracle 5.0.2 and Oracle 10g ) . If you have installed everything , get the oracle instant client and extract to your local folders.

Say example , I’ve extracted it to c:\insOracle\

Now, We should create or update ORACLE_HOME and PATH variable for instant client.

from console ,

 
set ORACLE_HOME = C:\insOracle\
 
PATH = %PATH%;C:\insOracle\

Or you can add it to your system path using windows path editor.

That’s it. Now we can connect to oracle from python. Make sure that you don’t use “;” at the end of your queries from python.

Export MySQL database in XML format

This small python program can export mysql database in a xml format

import MySQLdb
 
hostName="hostnamehere"
userName="usernamehere"
passWd="passwordhere"
dbName="dbnamehere"
 
print "Started...."
 
#open file
file = open("out.xml", 'w')
 
file.write("");
file.write("\n\t<" + dbName + ">");
 
print "Connecting to " , hostName , "...";
conn=MySQLdb.connect(host=hostName,user=userName,passwd=passWd,db=dbName)
cursor = conn.cursor ()
 
table_list = []
 
#get server version
cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
server_version = row[0];
print "Detected MySQL version ", server_version
 
# get all the tables
print "Getting tables...";
cursor.execute("show tables");
for row in cursor:
table_list.append(row[0])
 
# lets get all the tables values
for table in table_list:
file.write("\n\t<" + table + ">");
print "Processing ", table , " ..."
sql_desc = "desc " + table;
cursor.execute(sql_desc);
type_list = []
for row in cursor:
type_list.append(row[0])
# now data
sql_table_rows = "select * from " + table;
cursor.execute(sql_table_rows);
for row in cursor:
for i in range(len(type_list)):
file.write("\n\t\t<" + type_list[i] + ">" + "%s" %row[i] + "")
file.write("\n\t")
 
file.write("\n\t");
file.close();
print "XML file(out.xml) successfully written"