Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » code to more than one database and your threads
code to more than one database and your threads [message #56200] Mon, 08 February 2021 02:18 Go to next message
BetoValle is currently offline  BetoValle
Messages: 93
Registered: September 2020
Location: Brasil Valinhos SP
Member
Hi,

how do I adapt the server structure, to load more than one database and in different situations?

at the beginning there is only 1 database. In this situation the posted examples include. But it is assumed that in the same access create 2 other databases (all mysql) and make access etc.. along with the 1st database originally created.

how to build access with the 2 threads? how would it be?

SKYLARK(q, "qualqueres:POST")
{
	//..code to create or open others databases 
        //..and thread(s) 
}


could you give a simple example?

//first database when load server...
void OpenSQL(MySqlSession& session)
{
	
	if(!session.Connect("user", "password", "database")) {
		SKYLARKLOG("Can't connect to database");
		Exit(1);
	}

	SQL = session;
}

void demoTeste::WorkThread()
{
	MySqlSession session;
	OpenSQL(session);
	RunThread();
}


Thanks

Re: code to more than one database and your threads [message #56321 is a reply to message #56200] Sat, 20 February 2021 18:06 Go to previous message
mirek is currently offline  mirek
Messages: 13145
Registered: November 2005
Ultimate Member
BetoValle wrote on Mon, 08 February 2021 02:18
Hi,

how do I adapt the server structure, to load more than one database and in different situations?

at the beginning there is only 1 database. In this situation the posted examples include. But it is assumed that in the same access create 2 other databases (all mysql) and make access etc.. along with the 1st database originally created.

how to build access with the 2 threads? how would it be?

SKYLARK(q, "qualqueres:POST")
{
	//..code to create or open others databases 
        //..and thread(s) 
}


could you give a simple example?

//first database when load server...
void OpenSQL(MySqlSession& session)
{
	
	if(!session.Connect("user", "password", "database")) {
		SKYLARKLOG("Can't connect to database");
		Exit(1);
	}

	SQL = session;
}

void demoTeste::WorkThread()
{
	MySqlSession session;
	OpenSQL(session);
	RunThread();
}


Thanks



Well, obviously with 2 databases connected at the same time, you cannot use global database SQL for at least one of these.

That said, w.r.t. threading, there is a mode that keeps SQL thread-local: Check SqlSession::PerThread. In that case one thread can have different default global SqlSession than another.
Previous Topic: How to Sync computer Time in a network?
Goto Forum:
  


Current Time: Fri Mar 05 14:33:39 CET 2021

Total time taken to generate the page: 0.01052 seconds