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++ SQL » Sql Lite schema with DATE type
Sql Lite schema with DATE type [message #51733] Thu, 09 May 2019 11:23 Go to next message
NattyRoots is currently offline  NattyRoots
Messages: 2
Registered: April 2019
Junior Member
Hello,

I'm trying to create a SQL Lite 3 database where I would store the insertion Date. Here's my current .sch :

TABLE_ (SESSION)
	INT 	(SESSION_ID) PRIMARY_KEY AUTO_INCREMENT
	STRING_ (BATTLETAG, 200)
	STRING_ (DISCORD_NAME, 200)
	STRING_ (RANK, 4)
	DATE_ (DATE_SESSION) SQLDEFAULT(CURRENT_DATE)
END_TABLE


It compiles just fine but when I try to execute any SQL query, I get the following error and my .db file isn't updated :

Assertion failed in C:\UPP\upp-mingw-12999\upp\uppsrc\plugin\sqlite3\Sqlite3upp.cpp, line 270
NULL != current_stmt


I'm updating my .db file using the method found in the SQL Lite 3 reference :

Sqlite3Session sqlite3;
sqlite3.LogErrors(true);
if(!sqlite3.Open(ConfigFile("simple.db"))) {
	Cout() << "Can't create or open database file\n";
	return;
}
				
#ifdef _DEBUG
	SqlSchema sch(SQLITE3);
	All_Tables(sch);
	if(sch.ScriptChanged(SqlSchema::UPGRADE))
		SqlPerformScript(sch.Upgrade());
	if(sch.ScriptChanged(SqlSchema::ATTRIBUTES)) {
		SqlPerformScript(sch.Attributes());
	}
	if(sch.ScriptChanged(SqlSchema::CONFIG)) {
		SqlPerformScript(sch.ConfigDrop());
		SqlPerformScript(sch.Config());
	}
	sch.SaveNormal();
#endif


Is there a special way to deal with date using Sql Lite 3 in U++ ?

Thank you for your help !
Re: Sql Lite schema with DATE type [message #51736 is a reply to message #51733] Thu, 09 May 2019 16:32 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 287
Registered: October 2008
Location: France
Experienced Member
Hi NattyRoots,

Did you check that ?

https:// www.ultimatepp.org/forums/index.php?t=msg&goto=43918& ;SQ=6ba6f2a48c976cdebd1e926ccffe0f49&

Hope it helps
BR

Biobytes
Re: Sql Lite schema with DATE type [message #51739 is a reply to message #51736] Fri, 10 May 2019 15:05 Go to previous message
NattyRoots is currently offline  NattyRoots
Messages: 2
Registered: April 2019
Junior Member
Hello BioBytes,

Thank you for your answer ! But unfortunately it did not seems to be my problem.

I came up with a solution by storing a timestamp generated in C++ in my column DATE_SESSION, rather than using the SQLDEFAULT() :

.sch :
TABLE_ (SESSION)
	INT_ 	(SESSION_ID) PRIMARY_KEY AUTO_INCREMENT
	STRING_ (BATTLETAG, 200)
	STRING_ (DISCORD_NAME, 200)
	STRING_ (RANK, 4)
	INT_ (DATE_SESSION)
END_TABLE


Code :
std::chrono::milliseconds ms = std::chrono::duration_cast< std::chrono::milliseconds >(
     std::chrono::system_clock::now().time_since_epoch()
);
Sql sqlInsert;
sqlInsert*Insert(SESSION)(BATTLETAG, battletag)(DISCORD_NAME, userName)(RANK, rang)(DATE_SESSION, ms.count());


Thanks for the help anymway,

Natty

[Updated on: Fri, 10 May 2019 15:05]

Report message to a moderator

Previous Topic: Field name same as table name
Next Topic: postgresql mingw
Goto Forum:
  


Current Time: Fri Oct 30 14:13:00 CET 2020

Total time taken to generate the page: 0.01551 seconds