Saifi Khan | 24 Mar 2009 20:56
Favicon

Project completed

Hi all:

Effective today (24/03/2009), the prototype phase of DSwitch has
been completed and the project is closed.

The mailing list will the closed/deleted subsequent to this
mail.

The mail archives will always be available at
http://www.mail-archive.com/dswitch-Z7w6Ax9sQx0h9ZMKESR00Q <at> public.gmane.org/

The project website will continue to be available at
http://www.twincling.org/dswitch

the sourceforge repository of Twincling Foundation will host the
current checked in code.

Thank you to all those who contributed and assisted with the
project.

thanks
Saifi.
Phanindra | 24 Mar 2009 14:02
Picon

Code Uploaded

Hi,

I uploaded my code into
https://twincling.svn.sourceforge.net/svnroot/twincling/dswitch/src/libsource/mysql5.0.51/

Thank you,

Phanindra
Siddharth Pal | 23 Mar 2009 04:34
Picon

dswitch + doc upload

Hi Saifi,

So added
https://twincling.svn.sourceforge.net/svnroot/twincling/license/cpp.license
to each source file.

and uploaded all my codes along with the doc.
Phanindra will most probably upload his files in the evening

and i'll update the dswitch site after phani uploads his code.

https://twincling.svn.sourceforge.net/svnroot/twincling/dswitch/

and will create a topic on ASL2.0 on twincling's yahoo group in the evening :)

Regards,
Siddharth Pal

Saifi Khan | 23 Mar 2009 07:43
Favicon

Re: Regarding DSwitch license

On Sun, 22 Mar 2009, Siddharth Pal wrote:

> Or is adding our names and contact to the AUTHORS file enough?
> 

Yes, adding names and email to the AUTHORS file is enough.

Author name/email are *not* to be added to each file.
This information can be readily extracted by reviewing the Git
commit log/history.

thanks
Saifi.
Saifi Khan | 22 Mar 2009 06:43
Favicon

Re: DSwitch + Documentation upload

On Sat, 21 Mar 2009, Siddharth Pal wrote:

> Hi Saifi,
> 
> The DSwitch Doc is 1.58MB but the maximum size allowed for upload is 1MB.
> 
> I was planning to add a folder named "DSwitch" to
> https://twincling.svn.sourceforge.net/svnroot/twincling
> and upload it there, but thought it'd be better to ask you first, as
> this is the product resulting from the 1st phase and not the final
> product.
> 

The directory name needs to be 'dswitch' (all lowercase).

Under dswitch we'd have

 /docs/dswitch.odt

 /src/

You can create a tree locally on your machine, structure the
stuff and do a checkin.

Prior to that, please checkout the current twincling tree and
understand the module placements.

thanks
Saifi.
Saifi Khan | 20 Mar 2009 09:59
Favicon

Doc + Source

Hi Siddharth/Phanindra:

When you are done, please upload the 

 . dswitch sources as dswitch.tar.gz (only source code, no libs)
 . dswitch documentation as dswitch.pdf 

on the DSwitch website.

This way anybody interested can download the artifacts and get
started.

You guys have done a good job and appreciate your contribution
to Open Source.

thanks
Saifi.
Saifi Khan | 19 Mar 2009 17:29
Favicon

Project lists, archives and code consolidation

Hi all:

Quiet a few people complained about not being able to subscribe 
to the project mailing lists. This happened because of email 
based commands that ezmlm mailing list software requires.

Some people suggested that project hosting, lists, archives and
source code repository should be at the same location for ease
of access.

We'd like to ensure that all the current participants and future
participants are at ease dealing with lists, archives and code
repository.

The project information and documents will continue to be on 
Twincling.org website.

Folks, so this is a "one-time" and "last-time" migration of the
lists to their new location ie. sourceforge.net 
(not applicable to DSwitch project, as project has completed).

The old archives will continue to be at mail-archive.com and new
archives will be hosted off sourceforge.net as we seed the
lists.

The complete set of "new" lists is available at:
https://sourceforge.net/mail/?group_id=132563

Please subscribe to
 . twincling-commits
 . twincling-engg
 and
 . twincling-PROJECT list

thanks
Saifi.
Siddharth Pal | 13 Mar 2009 09:17
Picon

DSwitch Demo

Hi all,

I realized that the last demo code i posted was the incomplete one.
This is the complete one

Regards,
Siddharth Pal

Attachment (dswitch_demo.tar): application/x-tar, 1900 KiB

---------------------------------------------------------------------
To unsubscribe, e-mail: dswitch-unsubscribe@...
For additional commands, e-mail: dswitch-help@...
Siddharth Pal | 13 Mar 2009 06:53
Picon

Final demo code

hi all,

attached the source code with Makefiles...

just run ./dswitch
and try it out :)

Thanks,
Siddharth Pal

Attachment (dswitchdemo.tar): application/x-tar, 2030 KiB

---------------------------------------------------------------------
To unsubscribe, e-mail: dswitch-unsubscribe@...
For additional commands, e-mail: dswitch-help@...
Phanindra | 10 Mar 2009 16:23
Picon

MySQL to interim with all suggested changes

Im also sending the prog in attached file in case archiving problem occurs
Attachment (interimdb7.cpp): application/octet-stream, 20 KiB

---------------------------------------------------------------------
To unsubscribe, e-mail: dswitch-unsubscribe@...
For additional commands, e-mail: dswitch-help@...
Phanindra | 10 Mar 2009 16:21
Picon

MySQL to interim with all suggested changes

#include <QtSql>
#include <QString>
#include <QTextStream>
#include <QFile>
#include <stdio.h>
#include <QDateTime>
#include <stdlib.h>

QFile f1( "results.txt" );
QTextStream stream(&f1);

class ExtMySQL
{
	private:
		int arg;
		QStringList argl;
		QDateTime qd;
		QSqlDatabase db_source;
		QSqlDatabase db_int;    		
		QString dbn;
				
	public:
		ExtMySQL(int x, QStringList y)
		{
			arg=x;
			argl=y;
				
			QDateTime qd;

			f1.open( QFile::WriteOnly | QFile::Text );
			freopen ("error.txt","a",stderr);
			qDebug()<<"*********************Error Log*************************";
			qDebug()<<qd.currentDateTime()<< "\n";

			db_source=QSqlDatabase::addDatabase("QMYSQL");
			db_int=QSqlDatabase::addDatabase("QPSQL","second");
				
			db_source.setHostName("localhost");
			db_source.setUserName(argl[1]);
			db_source.setPassword(argl[2]);
	
			db_int.setHostName("localhost");
		    db_int.setUserName(argl[3]);
		    db_int.setPassword("hello");
			db_int.setDatabaseName("postgres");

		}
		int dSwitchMySQL();
		int tableExtract();
		int viewExtract();
		int triggerExtract();
		int indexExtract();
		int dataExtract();
		int funcExtract();
		int procExtract();
		
};	

int ExtMySQL::dSwitchMySQL()
{
	f1.open( QFile::WriteOnly | QFile::Text );
	
	freopen ("error.txt","a",stderr);
    qDebug()<<"*********************Error Log*************************";
	qDebug()<<qd.currentDateTime()<< "\n";

	if(db_source.open()==false)
    {
        qDebug() << "Can not open source database"<<"\n" <<
db_source.lastError()<<"\n";
        return -1;
    }
    else if(db_int.open()==false)
    {
        qDebug() << "Can not open intermediate database"<<"\n"<<
db_int.lastError()<<"\n";
        return -1;
    }
	else
	{
		qDebug() << "Opening Source database: " << argl[1] << db_source.lastError();
        qDebug() << "Opening interim database with the provided user
and password" << db_int.lastError()<<"\n";

		QSqlQuery psql_createdb_query(db_int);
        psql_createdb_query.exec("create database twincdbint");
        qDebug() << psql_createdb_query.lastError() << "line 83" << endl;
        db_int.close();
	    db_int.setDatabaseName("twincdbint");

		if(db_int.open()==false)
        {
			qDebug() << "Can not open intermediate database twincdbint"<<"\n"<<
db_int.lastError()<<"\n";
            return -1;
        }
		
		QSqlQuery psqldb_query(db_int);
		psqldb_query.exec("create table tblsch(tname varchar PRIMARY
KEY,tsql varchar,dname varchar,forkey int default 0)");
	    qDebug() << psqldb_query.lastError() << "line 95" << endl;

		QSqlQuery psql_indexsch_query(db_int);
	    psql_indexsch_query.exec("create table indexsch (idxname
varchar,tbl varchar,col varchar,sql varchar,dname varchar)");
	    qDebug() << psql_indexsch_query.lastError() << "line 99" << endl;
	    	
		QSqlQuery psql_trig_query(db_int);
	    psql_trig_query.exec("create table trigsch (trigname varchar,tbl
varchar, sql varchar,dname varchar)");
	    qDebug() << psql_trig_query.lastError() << "line 103" << endl;

		QSqlQuery psql_viewsch_query(db_int);
		psql_viewsch_query.exec("create table viewsch (viewname varchar,sql
varchar,dname varchar)");
	    qDebug() << psql_viewsch_query.lastError() << "line 107" <<endl;

		QSqlQuery psql_procsch_query(db_int);
		psql_viewsch_query.exec("create table procsch (proc_name varchar ,
proc_sql varchar , dname varchar )");
	    qDebug() << psql_viewsch_query.lastError() << "line 111" <<endl;

		QSqlQuery psql_funcsch_query(db_int);
		psql_funcsch_query.exec("create table funcsch (func_name varchar ,
func_sql varchar , dname varchar )");
	    qDebug() << psql_funcsch_query.lastError() << "line 115" <<endl;

//creating a list of databases
		psqldb_query.exec("create table dbl(dname varchar(30))");
        qDebug() << psqldb_query.lastError() << "line 119" << endl;
		
		QSqlQuery db_query;
		db_query.exec("show databases");
        qDebug() << db_query.lastError() <<" line 123" <<endl;
        stream << "List of Databases:\n";
		
		QSqlQuery psql_dbs_query(db_int);

		while(db_query.next())
        {
			QString dbstr=db_query.value(0).toString();
			if(dbstr.compare("information_schema") && dbstr.compare("mysql"))
			{
				dbstr.replace("'","''");
				psql_dbs_query.exec("insert into dbl values('"+dbstr+"')");
				qDebug() << psql_dbs_query.lastError() << "line 133" << endl;
				stream << dbstr << endl;
			}
        }
//extracting each database
		db_query.first();
        db_query.previous();
        int n;

		while(db_query.next())
		{
			
			dbn=db_query.value(0).toString();
			
			n=tableExtract();
			if(!n)
			{
				stream <<"error while extracting table creation stmt\n";
			}

			n=dataExtract();
			if(!n)
			{
				stream <<"error while extracting procedure creation stmt\n";
			}

			n=triggerExtract();
			if(!n)
			{
				stream <<"error while extracting trigger creation stmt\n";
			}

			n=indexExtract();
			if(!n)
			{
				stream <<"error while extracting index creation stmt\n";
			}

			n=procExtract();
			if(!n)
			{
				stream <<"error while extracting procedure creation stmt\n";
			}

			n=funcExtract();
			if(!n)
			{
				stream <<"error while extracting procedure creation stmt\n";
			}

			n=viewExtract();
			if(!n)
			{
				stream <<"error while extracting view creation stmt\n";
			}

			

		}	
	}	
	qDebug();
	stream <<"***********************************************************"
<< "\n\n";
	//f1.close();
	fclose (stderr);

	db_source.close();
	db_int.close();
	return 1;
}//dswitchMySQL()

int ExtMySQL::tableExtract()
{
	if(dbn.compare("information_schema") &&	dbn.compare("mysql"))
	{
		stream << "\nThe contents of the database: " << dbn << "\n";
		QSqlQuery tbl_count_query,tbl_query,tbl_col_query,fk_query;
		QSqlQuery psql_tbl_create(db_int),psqldb_query(db_int),psql_tbl_query(db_int),psql_tbldata_ins(db_int);
        tbl_count_query.exec("select count(table_name) from
information_schema.tables where table_schema='"+dbn+"'");
        qDebug() << tbl_count_query.lastError() << "line 61 " << endl;
        if(tbl_count_query.next())
			stream << tbl_count_query.value(0).toInt() << " tables" << endl;

		stream<<"\n The list and details of the tables:\n";
        tbl_query.exec("show tables from "+dbn);
        qDebug() << tbl_query.lastError() << "line 68" << endl;
		int n=1;
        while(tbl_query.next())
        {
			int prim=0;
			stream << n <<". ";
			QString tbl_name=tbl_query.value(0).toString();
			stream << tbl_name << endl;

			psql_tbl_create.exec(" create table "+tbl_name+"_d ( col_name
varchar , col_type varchar , prim int )");
			qDebug() << psql_tbl_create.lastError() << "line 231" << endl;

			QString tbl_sql="create table "+tbl_name+"( \n";

			stream << "\n   List of columns and their details:\n";

			tbl_col_query.exec("show columns from "+dbn+"."+tbl_name);
			qDebug() << tbl_col_query.lastError() << "line 240 "<<endl;
			while(tbl_col_query.next())
			{
				QString col_name=tbl_col_query.value(0).toString();
				QString col_type=tbl_col_query.value(1).toString();
				QString col_null=tbl_col_query.value(2).toString();
				if(!col_null.compare("YES"))
					col_null="";
				else
					col_null="NOT NULL";

				QString col_key=tbl_col_query.value(3).toString();
				if(!col_key.compare("MUL"))
				{	
					col_key="";
					prim=1;
				}
				else if(!col_key.compare("PRI"))
				{
					col_key="PRIMARY KEY";
					prim=0;
				}

				QString colins_sql;
				QString q="";
				q.append(QString::number(prim,10));
				colins_sql=" insert into "+tbl_name+"_d values (
'"+col_name+"','"+col_type+"','"+q+"' ) ";
				psql_tbldata_ins.exec(colins_sql);
				qDebug() << psql_tbldata_ins.lastError() << "line 267" << endl;

				QString col_default=tbl_col_query.value(4).toString();
				if(!col_key.compare("PRIMARY KEY"))
					col_default="";
				else if(!col_default.compare(NULL))
					col_default="default NULL";
				else
					col_default="default "+col_default;

				stream<<"   "<<col_name<< " " << col_type << " " << col_null << "
" <<col_key << " " << col_default<<endl;
				QString tbl_sql2=col_name+" "+col_type+" "+col_null+" "+col_key +"
"+col_default+", \n";
				tbl_sql.append(tbl_sql2);
			}

			stream << "\n   List of foreign keys:\n";
			fk_query.exec("show create table    "+dbn+"."+tbl_name);
			qDebug() << fk_query.lastError() << "line 285" <<endl;

			while(fk_query.next())
			{
				QString fk_name=fk_query.value(1).toString();
				QString fk_check="FOREIGN KEY";
				int pos=0,ini=0;
				while((pos=fk_name.indexOf(fk_check,ini))!=-1)
				{
					ini=fk_name.indexOf("`)",pos);
					ini=fk_name.indexOf("`)",ini+1);
					QString for_key=fk_name.mid(pos,ini-pos+2);
					stream<<" "<<for_key<<endl;
					QString tbl_sql3=for_key+", \n";
					tbl_sql.append(tbl_sql3);
				}
			}

			tbl_sql.append(")");
			int cpos=tbl_sql.indexOf(", \n)");
			tbl_sql.replace(cpos,3,"");
			stream<<"\n   SQL code:\n";
			stream<<"   "<<tbl_sql;
			stream<<"\n\n";
			tbl_sql.replace("'","''");
			psql_tbl_query.exec("insert into tblsch
values('"+tbl_name+"','"+tbl_sql+"','"+dbn+"') ");
			qDebug() << psql_tbl_query.lastError() << "line 291"<<endl;
			n++;
		}
	}
	return 1;
}//tableExtract()

int ExtMySQL::dataExtract()
{
	if(dbn.compare("information_schema") && dbn.compare("mysql"))
    {	
		QSqlQuery tbl_query;
		tbl_query.exec("show tables from "+dbn);
		qDebug() << tbl_query.lastError() << "line 324"<<endl;
		while(tbl_query.next())
        {
			QSqlQuery tbl_col_query,tbl_data_query;
			QSqlQuery psql_tbl_create(db_int),psql_data_query(db_int);
			QString tbl_name=tbl_query.value(0).toString();
			stream << " \n The table data is \n";
			stream << "----------------------------------------------\n";

			QString creat_sql="";
			tbl_col_query.exec("show columns from "+dbn+"."+tbl_name);
			qDebug() << tbl_col_query.lastError() << "line 335"<<endl;
			
			int n=tbl_col_query.size();
			int count=0;
			while(tbl_col_query.next())
			{
				count++;
				QString q=tbl_col_query.value(0).toString();
				stream << q <<"     ";
				if (count!=n)
					creat_sql.append(" "+q+" bytea , ");
				else
					creat_sql.append(" "+q+" bytea ");

			}
			stream << "\n----------------------------------------------\n";
			QString createtbl_sql;
			createtbl_sql="create table "+tbl_name+"_"+dbn+" ("+creat_sql+")";
			psql_tbl_create.exec(createtbl_sql);
			qDebug() << psql_tbl_create.lastError() << "line 354"<<endl;
			
			tbl_data_query.exec("select * from "+dbn+"."+tbl_name);
			qDebug() << tbl_data_query.lastError() << "line 357"<<endl;
			QString tbl_data,tbl_data1;

			while(tbl_data_query.next())
			{
				tbl_data="";
				for( int i=0; i< tbl_col_query.size();i++)
				{
					stream << tbl_data_query.value(i).toString() <<"  ";
					tbl_data.append("'");
					tbl_data1 = tbl_data_query.value(i).toString();
					tbl_data1.replace("'","''");
					tbl_data.append(tbl_data1);
					tbl_data.append("'");
					if(i!=n-1)
						tbl_data.append(",");
				}
				psql_data_query.exec("insert into "+tbl_name+"_"+dbn+"
values("+tbl_data+")");
				qDebug() << psql_data_query.lastError() << "line 375"<<endl;
				stream << "\n";
			}
		}

	}
	return 1;

}//dataExtract()

int ExtMySQL::viewExtract()
{
	if(dbn.compare("information_schema") && dbn.compare("mysql"))
    {
		stream << "\nThe Views of database "<< dbn <<" are\n";
		QSqlQuery db_view_query,view_create_query,set_ansi_query,usedb_query;
		QSqlQuery psql_viewsql_query(db_int);
		usedb_query.exec("use "+dbn+" ");
		qDebug() << db_view_query.lastError() << "line 394" <<endl;
		db_view_query.exec("select * from information_schema.views where
TABLE_SCHEMA='"+dbn+"'");
		qDebug() << db_view_query.lastError() << "line 396" <<endl;
		stream << db_view_query.size()<<"\n";
		int count=1;
		while(db_view_query.next())
		{
			QString view_sql,view_name = db_view_query.value(2).toString();
			stream << count <<"."<< view_name << "\n\n";
			stream << "view creation statement is \n\n";
			set_ansi_query.exec("set sql_mode='ansi' ");
			qDebug() << set_ansi_query.lastError() << "line 405" <<endl;
			view_create_query.exec("show create view "+dbn+"."+view_name+"");
			qDebug() << db_view_query.lastError() << "line 407" <<endl;
			view_create_query.first();
			stream << view_create_query.value(1).toString()<<"\n";
			view_sql = view_create_query.value(1).toString();
			view_sql.replace("_latin1","");
			view_sql.replace("'","''");
			psql_viewsql_query.exec("insert into viewsch
values('"+view_name+"','"+view_sql+"','"+dbn+"')");
			qDebug() << psql_viewsql_query.lastError() << "line 414" <<endl;
			count++;
		}
	}
	return 1;
}//viewExtract()

int ExtMySQL::triggerExtract()
{
	if(dbn.compare("information_schema") && dbn.compare("mysql"))
    {
		QSqlQuery trig_count_query,trig_query;
		QSqlQuery psql_trigsql_query(db_int);
		stream << "\nTriggers in database: " << dbn << "\n";
		trig_count_query.exec("select count(trigger_name) from
information_schema.triggers where trigger_schema='"+dbn+"'");
		qDebug() << trig_count_query.lastError() << "line 429" << endl;
		if(trig_count_query.next())
		stream << trig_count_query.value(0).toInt() << " Triggers" << endl;

		stream<<"\n The list and details of the triggers:\n";
		trig_query.exec("show triggers from "+dbn);
		qDebug() << trig_query.lastError() << "line 435" << endl;
		int n=1;
		
		while(trig_query.next())
		{
			stream << n <<". ";
			QString trig_name=trig_query.value(0).toString();
			stream << trig_name << endl;

			QString trig_tbl=trig_query.value(2).toString();
			stream << "   On table: " << trig_tbl << endl;

			QString trig_event=trig_query.value(1).toString();
			QString trig_timing=trig_query.value(4).toString();
			QString trig_stmt=trig_query.value(3).toString();

			stream << "   SQL code:\n   ";
			QString trig_sql="CREATE TRIGGER "+trig_name+" "+trig_timing+"
"+trig_event+" ON "+trig_tbl+" FOR EACH ROW "+trig_stmt;
			stream << trig_sql << "\n\n";
			n++;
			trig_sql.replace("'","''");
			psql_trigsql_query.exec("insert into trigsch
values('"+trig_name+"','"+trig_sql+"','"+dbn+"')");
			qDebug() << psql_trigsql_query.lastError() << "line 457" << endl;
		}
	}

	return 1;
}//triggerExtract()

int ExtMySQL::indexExtract()
{
	if(dbn.compare("information_schema") && dbn.compare("mysql"))
    {
		QSqlQuery idx_count_query,idx_info_query,idx_colnum_query,idx_query;
		QSqlQuery psql_idx_query(db_int),psql_idxsql_query(db_int);
		stream << "\nIndex in database: " << dbn << "\n";
		idx_count_query.exec("select count(distinct(index_name)) from
information_schema.statistics where table_schema='"+dbn+"' and
INDEX_NAME NOT LIKE 'PRIMARY'");
		qDebug() << idx_count_query.lastError() << "line 472" << endl;
		if(idx_count_query.next())
		stream << idx_count_query.value(0).toInt() << " indices" << endl;

		stream<<"\n The list and details of the Index:\n";
		idx_query.exec("select distinct(index_name) from
information_schema.statistics where table_schema='"+dbn+"' and
INDEX_NAME NOT LIKE 'PRIMARY'");
		qDebug() << idx_query.lastError() << "line 478" << endl;
		int n=1;
		
		while(idx_query.next())
		{
			stream << n <<". ";
			QString idx_name=idx_query.value(0).toString();
			stream << idx_name << endl;

			idx_info_query.exec("select * from information_schema.statistics
where table_schema='"+dbn+"' and INDEX_NAME='"+idx_name+"'");
			qDebug() << idx_info_query.lastError() << "line 488" << endl;

			while(idx_info_query.next())
			{
				idx_colnum_query.exec("select count(*) from
information_schema.statistics where table_schema='"+dbn+"' and
INDEX_NAME='"+idx_name+"'");
				qDebug() << idx_colnum_query.lastError() << "line 493" << endl;

				int idx_colnum=0;
				if(idx_colnum_query.next())
				idx_colnum=idx_colnum_query.value(0).toInt();

				QString idx_tbl=idx_info_query.value(2).toString();
				stream << "   On table: " << idx_tbl << endl;

				QString idx_uni;
				int idx_unique=idx_info_query.value(3).toInt();
				if(idx_unique==1)
				idx_uni="";
				else
				idx_uni=" UNIQUE";
				QString idx_col;
				idx_col=idx_info_query.value(7).toString();

				QString idx_type=idx_info_query.value(13).toString();

				QString idx_sql;
				stream << "   SQL code:\n   ";
				idx_sql=" CREATE INDEX "+idx_uni+" "+idx_name+" USING "+idx_type+"
ON "+idx_tbl+" ( ";

				while(idx_colnum!=0)
				{
					QString idx_col=idx_info_query.value(7).toString();

					QString idx_sublen=idx_info_query.value(10).toString();
					if(!idx_sublen.compare("0"))
					idx_sublen="";
					else
					idx_sublen=" ("+idx_sublen+") ";

					idx_sql=idx_sql+idx_col+idx_sublen+", ";
					--idx_colnum;
					idx_info_query.next();
				}

				idx_sql.append(")");
				int cpos=idx_sql.indexOf(", )");
				idx_sql.replace(cpos,    1,"");
				stream << idx_sql << "\n\n";
				n++;
				idx_sql.replace("'","''");
				psql_idxsql_query.exec("insert into indexsch
values('"+idx_name+"','"+idx_tbl+"','"+idx_col+"','"+idx_sql+"','"+dbn+"')");
				qDebug() << psql_idxsql_query.lastError() << "line 539" << endl;
			}
		}
	}
	return 1;
}//indexExtract()

int ExtMySQL::procExtract()
{
	if(dbn.compare("information_schema") && dbn.compare("mysql"))
    {
		
		stream<< "\n The procedures of database" << dbn << " are:\n";

		QSqlQuery db_proc_query,proc_create_query,db_procount_query;
		QSqlQuery psql_procsql_query(db_int);

		db_proc_query.exec("select * from mysql.proc where db='"+dbn+"' and
type='PROCEDURE' ");
		qDebug() << db_proc_query.lastError() << "line 557" <<endl;
		stream << db_proc_query.size() <<"\n";
		int count = 1;
		
		while(db_proc_query.next())
		{
			QString proc_sql,proc_name = db_proc_query.value(1).toString();
			stream << count <<"."<< proc_name << "\n\n";
			stream << "Procedure creation statement is \n\n";
			proc_create_query.exec("show create procedure "+dbn+"."+proc_name+"");
			qDebug() << proc_create_query.lastError() << "line 567" <<endl;
			proc_create_query.first();
			stream << proc_create_query.value(2).toString()<<"\n";
			count++;
			proc_sql = proc_create_query.value(2).toString();
			proc_sql.replace("'","''");
			psql_procsql_query.exec("insert into procsch
values('"+proc_name+"','"+proc_sql+"','"+dbn+"')");
			qDebug() << psql_procsql_query.lastError() << "line 574" <<endl;
		}
	}
	return 1;
}//procExtract()

int ExtMySQL::funcExtract()
{
	if(dbn.compare("information_schema") && dbn.compare("mysql"))
    {
		
		stream<< "\n The functions of database" << dbn << " are:\n";
		QSqlQuery db_func_query,func_create_query;
		QSqlQuery psql_funcsql_query(db_int);
		db_func_query.exec("select * from mysql.proc where db='"+dbn+"' and
type='FUNCTION'");
		qDebug() << db_func_query.lastError() << "line 589" <<endl;
		stream << db_func_query.size() <<"\n";
		int count = 1;
		while(db_func_query.next())
		{
			QString func_sql,func_name;
			func_name = db_func_query.value(1).toString();
			stream << count <<"."<< func_name << "\n\n";
			stream << "Function creation statement is \n\n";
			func_create_query.exec("show create function "+dbn+"."+func_name);
			qDebug() << func_create_query.lastError() << "line 599" <<endl;
			func_create_query.first();
			stream << func_create_query.value(2).toString()<<"\n";
			count++;
			func_sql = func_create_query.value(2).toString();
			func_sql.replace("'","''");
			psql_funcsql_query.exec("insert into funcsch
values('"+func_name+"','"+func_sql+"','"+dbn+"')");
			qDebug() << psql_funcsql_query.lastError() << "line 606" <<endl;
		}
	}

	return 1;
}//funcExtract

int main(int argc, char *argv[])
{
	if(argc!=5)
    {
		printf("Error: Insufficient parameters - Execute the program as: \n");
        printf("./<executable file> <MySql username> <MySql password>
<psql username> <psql pass>\n");
        exit(1);
    }
	QStringList ql;
	ql << argv[0] << argv[1] << argv[2] << argv[3] << argv[4];
	ExtMySQL *e=new ExtMySQL(argc,ql);
	int res=e->dSwitchMySQL();
	if(res==1)
		printf("Success");
	else
		printf("Failed");
}

to execute
./<executable file> <MySql username> <MySql password> <psql username>
<psql pass>

Thanks,

Phanindra

Gmane