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  |
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 #51739 is a reply to message #51736] |
Fri, 10 May 2019 15:05  |
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
|
|
|
Goto Forum:
Current Time: Tue Apr 29 15:08:51 CEST 2025
Total time taken to generate the page: 0.01183 seconds
|