Reviving DatabaseLayer
-
- Earned a small fee
- Posts: 21
- Joined: Tue Mar 26, 2013 3:52 am
Re: Reviving DatabaseLayer
The "Dbl" in wxDblConfig was meant to be an abbreviation for "DataBaseLayer". wxDblConfig is exclusively implemented to run on top of the DatabaseLayer. I'll convert it to run on top of wxDatabase and then perhaps we'll rename it to wxDatabaseConfig.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
Ah! I understand. It will be cool to have it!manyleaves wrote:The "Dbl" in wxDblConfig was meant to be an abbreviation for "DataBaseLayer". wxDblConfig is exclusively implemented to run on top of the DatabaseLayer. I'll convert it to run on top of wxDatabase and then perhaps we'll rename it to wxDatabaseConfig.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Reviving DatabaseLayer
Sam wrote:Could you please consider to add ODBC in?I have issues on it when working with aisa characters and I can't fix it.
Appreicated.
I just tested the ODBC part.As I mentioned earlier in the post,I encountered problems on Chinese characters on windows when interact with MS Access database with DatabaseLayer.This time for wxDabase,I tried DSNless connects to MS Access file,God,it works pretty good!I tried the metadata part,it works great as well!I tried to run a select query and no problem at all;I tried the preparedStatement (param query),it works;evstevemd wrote: Hi Sam,
I cannot promise anything right now. But definitely, I would like to make the library as alive as possible.
Let me see if I can undertake that as far as time resource is concerned!
regards,
Stefano
When I tried to insert new record with PreparedStatement,it works,the data has been written back to the Access and I can read it and print its value with wxMessageBox;but the new string value (wxString type) get inserted into the Access file can't be recognizable in MS Access!That means,in my wx GUI program,the new record in the Access file can be show correctly in wxMessageBox(),but it is unrecognizable in MS Access itself!
Below is the key part of the code:
Code: Select all
wxString newRow=wxT("使用wx程序插入一条新记录");
wxPreparedStatement* stat=db.PrepareStatement(wxT("Insert into artists values (?,?);"));
stat->SetParamInt(1,12);
stat->SetParamString(2,newRow);
int rowAffected=stat->ExecuteUpdate();
stat->Close();
wxMessageBox(wxString::Format(wxT("%d row affected."),rowAffected));
Code: Select all
wxString newRow=wxString::Format(wxT("insert into artists values(%d,'%s');"),7,wxT("待插入记录"));
rowAffected=db.RunQuery(newRow,false);
wxMessageBox(wxString::Format(wxT("%d row affected."),rowAffected));
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
Can you make a minimal app that I can use to test your case?samsam598 wrote:Sam wrote:Could you please consider to add ODBC in?I have issues on it when working with aisa characters and I can't fix it.
Appreicated.I just tested the ODBC part.As I mentioned earlier in the post,I encountered problems on Chinese characters on windows when interact with MS Access database with DatabaseLayer.This time for wxDabase,I tried DSNless connects to MS Access file,God,it works pretty good!I tried the metadata part,it works great as well!I tried to run a select query and no problem at all;I tried the preparedStatement (param query),it works;evstevemd wrote: Hi Sam,
I cannot promise anything right now. But definitely, I would like to make the library as alive as possible.
Let me see if I can undertake that as far as time resource is concerned!
regards,
Stefano
When I tried to insert new record with PreparedStatement,it works,the data has been written back to the Access and I can read it and print its value with wxMessageBox;but the new string value (wxString type) get inserted into the Access file can't be recognizable in MS Access!That means,in my wx GUI program,the new record in the Access file can be show correctly in wxMessageBox(),but it is unrecognizable in MS Access itself!
Below is the key part of the code:And I found that below code does not work,when program runs to this sentence,it crashed.Please note there is no record whose index=7 at this moment.Code: Select all
wxString newRow=wxT("使用wx程序插入一条新记录"); wxPreparedStatement* stat=db.PrepareStatement(wxT("Insert into artists values (?,?);")); stat->SetParamInt(1,12); stat->SetParamString(2,newRow); int rowAffected=stat->ExecuteUpdate(); stat->Close(); wxMessageBox(wxString::Format(wxT("%d row affected."),rowAffected));
Code: Select all
wxString newRow=wxString::Format(wxT("insert into artists values(%d,'%s');"),7,wxT("待插入记录")); rowAffected=db.RunQuery(newRow,false); wxMessageBox(wxString::Format(wxT("%d row affected."),rowAffected));
If you use CodeLite or CodeBlocks, just make a small project and attach it here.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Reviving DatabaseLayer
Great thanks for the help in advance.
I've attached the C::B project.The MS Access file is under /DB/ folder.For wxDatabase,I included the whole source except sqlite3&,postgresql & mysql part.
Regards,
Sam
I've attached the C::B project.The MS Access file is under /DB/ folder.For wxDatabase,I included the whole source except sqlite3&,postgresql & mysql part.
Regards,
Sam
- Attachments
-
- NewDBtest.7z
- (23.42 KiB) Downloaded 235 times
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
Give me little time and I will test and find the issue and try to fix themsamsam598 wrote:Great thanks for the help in advance.
I've attached the C::B project.The MS Access file is under /DB/ folder.For wxDatabase,I included the whole source except sqlite3&,postgresql & mysql part.
Regards,
Sam
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
Since I have hard time setting up C::B and my CL debugger is not working I have to wait a minute while Eran is fixing.evstevemd wrote:Give me little time and I will test and find the issue and try to fix themsamsam598 wrote:Great thanks for the help in advance.
I've attached the C::B project.The MS Access file is under /DB/ folder.For wxDatabase,I included the whole source except sqlite3&,postgresql & mysql part.
Regards,
Sam
The Code just crashes with stupid error that I cannot understand, so I have to debug
BTW I work under Linux not Windows.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Reviving DatabaseLayer
Appreciated.Please take your time.
Apologies for previous attached code.I forgot I added an custom funtion GetColumnTypeName(int i) for MetaData.I re-attached the source.
Btw,do you think the encoding of the source file matters?It is UTF-8.
Regards,
Sam
Apologies for previous attached code.I forgot I added an custom funtion GetColumnTypeName(int i) for MetaData.I re-attached the source.
Btw,do you think the encoding of the source file matters?It is UTF-8.
Regards,
Sam
- Attachments
-
- NewDBtest.7z
- (23.42 KiB) Downloaded 232 times
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
How does GetColumnTypeName differ with GetColumnType?samsam598 wrote:Appreciated.Please take your time.
Apologies for previous attached code.I forgot I added an custom funtion GetColumnTypeName(int i) for MetaData.I re-attached the source.
Btw,do you think the encoding of the source file matters?It is UTF-8.
Regards,
Sam
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Reviving DatabaseLayer
I meant I forgot that in previous code ,there is a GetColumnTypeName(int i) function over there which will prevent the compiling from work.In the updated code,I removed it and replaced with GetColumnType.Now the code can be compiled .
For GetColumnTypeName(int i),actually it is just a copy of GetColumnType(int i),the only diffence is to return wxString other than int.Just return "INTEGER" when it returns "1" in GetColumnType(int).Anyhow,you can forget it now as I've already removed it from the updated source code.
Regards,
Sam
For GetColumnTypeName(int i),actually it is just a copy of GetColumnType(int i),the only diffence is to return wxString other than int.Just return "INTEGER" when it returns "1" in GetColumnType(int).Anyhow,you can forget it now as I've already removed it from the updated source code.
Regards,
Sam
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
I tried on Linux I could not get it work (its drivers are commercial. I will try to work it tomorrow on windows machine)samsam598 wrote:I meant I forgot that in previous code ,there is a GetColumnTypeName(int i) function over there which will prevent the compiling from work.In the updated code,I removed it and replaced with GetColumnType.Now the code can be compiled .
For GetColumnTypeName(int i),actually it is just a copy of GetColumnType(int i),the only diffence is to return wxString other than int.Just return "INTEGER" when it returns "1" in GetColumnType(int).Anyhow,you can forget it now as I've already removed it from the updated source code.
Regards,
Sam
BTW I already fixed that will old attachment!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Reviving DatabaseLayer
This is only for your easy reference as I guess the issue is still not fixed at some level.Please take note my wx is Unicode+static build.See signature for more information.
In DatabaseStringConverter.cpp of DatabaseLayer (PS:I tested here just because it has a test case program),I made below modifications on the convertion part,the original code has been commented.With this change,using the same project (with small modifications on the naming conventions of course) I've attached here.It seems so far everything is fine.The preivous mentioned issue disappeared.
But however,in the test case provided by DatabaseLayer,the UnitTest failed .I will provide the error message at the end of the post.
Running the test case in the DatabaseLayer/tests/runner_odbc.exe:
In DatabaseStringConverter.cpp of DatabaseLayer (PS:I tested here just because it has a test case program),I made below modifications on the convertion part,the original code has been commented.With this change,using the same project (with small modifications on the naming conventions of course) I've attached here.It seems so far everything is fine.The preivous mentioned issue disappeared.
But however,in the test case provided by DatabaseLayer,the UnitTest failed .I will provide the error message at the end of the post.
Code: Select all
const wxCharBuffer DatabaseStringConverter::ConvertToUnicodeStream(const wxString& inputString)
{
#if wxUSE_UNICODE
//return wxConvUTF8.cWC2MB(inputString.wc_str(*wxConvCurrent));
//return (const char*)wxConvCurrent->cWX2MB(inputString);
return inputString.c_str();
#else
wxString str(inputString.wc_str(*wxConvCurrent), wxConvUTF8);
return str.mb_str();
#endif
}
const wxCharBuffer DatabaseStringConverter::ConvertToUnicodeStream(const wxString& inputString, const char* encoding)
{
#if wxUSE_UNICODE
//return wxConvUTF8.cWC2MB(inputString.wc_str(*wxConvCurrent));
// return (const char*)wxConvCurrent->cWX2MB(inputString);
return inputString.c_str();
#else
wxString str(inputString.wc_str(*wxConvCurrent), wxConvUTF8);
return str.mb_str();
#endif
}
Running the test case in the DatabaseLayer/tests/runner_odbc.exe:
Code: Select all
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\shu>cd\
C:\>cd person\lovedev\sdk\databaselayer\tests
C:\person\lovedev\sdk\databaselayer\tests>runner_odbc
+ MyTestSuite
- MyTestSuite::testInsertRecords
- MyTestSuite::testInsertRecordsWithPreparedStatements
- MyTestSuite::testMultipartInserts
- MyTestSuite::testMultipartInsertsWithResults
- MyTestSuite::testMultipartStatements
- MyTestSuite::testResults
- MyTestSuite::testPreparedStatementResults
- MyTestSuite::testSelectCorrectRecord
- MyTestSuite::testSelectCorrectRecordFromPreparedStatement
- MyTestSuite::testRollback
- MyTestSuite::testRollbackComplexSequence
- MyTestSuite::testDateTimeParameters
- MyTestSuite::testDateTimeParametersBefore1970
- MyTestSuite::testDateResultSetField
- MyTestSuite::testBinaryBlobParametersSimpleRetrieval
- MyTestSuite::testBinaryBlobParametersPreparedRetrieval
- MyTestSuite::testChangePreparedStatementParameters
- MyTestSuite::testSetPreparedStatementParametersOutOfOrder
- MyTestSuite::testManyBlobRecordRetrieval
- MyTestSuite::testLoopingPreparedStatement
- MyTestSuite::testLoopingPreparedStatementRetrieval
- MyTestSuite::testResultSetNext
- MyTestSuite::testFieldNotInResultSetError
- MyTestSuite::testNullValues
- MyTestSuite::testNullParameters
- MyTestSuite::testSingleLinePreparedStatement
- MyTestSuite::testEncodingSupport
- MyTestSuite::testParameterEncodingSupport
- MyTestSuite::testResultsByIndex
- MyTestSuite::testPreparedStatementResultsByIndex
- MyTestSuite::testResultSetMetaData
- MyTestSuite::testResultSetMetaDataForNullValues
- MyTestSuite::testResultSetAlias
- MyTestSuite::testViewAlias
- MyTestSuite::testSemicolonInsideStatement
- MyTestSuite::testDatabaseLayerWrappers
- MyTestSuite::testPreparedStatementWrappers
- MyTestSuite::testTextRemnants
- MyTestSuite::testDatabaseGarbageCollection
- MyTestSuite::testIsFieldNull
- MyTestSuite::testDateWithoutTime
- MyTestSuite::testDateWithoutTimePreparedStatement
- MyTestSuite::testTableExists
- MyTestSuite::testViewExists
- MyTestSuite::testGetTables
- MyTestSuite::testGetViews
- MyTestSuite::testGetColumns
- MyTestSuite::testCloseBeforeDelete
- MyTestSuite::testIsOpen
- MyTestSuite::testSingleResult
- MyTestSuite::testSingleResultNoResults
- MyTestSuite::testSingleResultNonUniqueResults
- MyTestSuite::testResultArrayInt
- MyTestSuite::testResultArrayString
- MyTestSuite::testResultArrayLong
- MyTestSuite::testResultArrayDouble
- MyTestSuite::testMemoryBufferBlobParameter
- MyTestSuite::testSmallMemoryBuffer
- MyTestSuite::testLargeMemoryBuffer
- MyTestSuite::testReusePreparedStatementWithResults
- MyTestSuite::testRunQueryReturnValue
- MyTestSuite::testPreparedStatementRunQueryReturnValue
- MyTestSuite::testBadPreparedStatement
- MyTestSuite::testResultSetNoRecords
- MyTestSuite::testSpecialCharactersInPreparedStatement
Error loading database specific SQL statementsF
terminate called after throwing an instance of 'TestFailedException'
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
C:\person\lovedev\sdk\databaselayer\tests>
Last edited by samsam598 on Wed May 15, 2013 8:45 am, edited 2 times in total.
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
Hi,
thanks for your feedback. I had to suspend my test as I have to Port my whole project and start working on Windows (well, wxDatabase is part of that project).
I will finish the task today and possibly tomorrow I'll try to fix the error in Unit Test as well as review your changed (and commit?)
Thanks for the feedback!
thanks for your feedback. I had to suspend my test as I have to Port my whole project and start working on Windows (well, wxDatabase is part of that project).
I will finish the task today and possibly tomorrow I'll try to fix the error in Unit Test as well as review your changed (and commit?)
Thanks for the feedback!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Reviving DatabaseLayer
Hi All,
I'm now working with wxDatabase but I find that it will be hard to maintain for two main reasons:
1. I do not use it at all so I find it difficult to maintain when adding new features/deciding depreacted ones
2. I cannot test it on windows since my dev combo is set on Linux.
So am dropping ODBC part unless someone else want to maintain that part (Just like different maintainers for wx ports).
I will wait for a while if no one volunteers am going to drop it!
I'm now working with wxDatabase but I find that it will be hard to maintain for two main reasons:
1. I do not use it at all so I find it difficult to maintain when adding new features/deciding depreacted ones
2. I cannot test it on windows since my dev combo is set on Linux.
So am dropping ODBC part unless someone else want to maintain that part (Just like different maintainers for wx ports).
I will wait for a while if no one volunteers am going to drop it!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
-
- Earned a small fee
- Posts: 21
- Joined: Tue Mar 26, 2013 3:52 am
Re: Reviving DatabaseLayer
Hi evstevmd
Not quite sure I understand your last post. "I'm now working with wxDatabase" and "I do not use it at all" seem contradictory!
Anyway, yesterday I downloaded your latest wxDatabase and merged my TDS and ODBC fixes and all the tests back into your code. In what I've put together we have MySql, PostGreSQL, Sqlite3, ODBC and TDS. I've run the tests for ODBC and TDS and they both pass all 65.
As I mentioned in an earlier post, I'm exclusively a VC++ developer on Windows so I've also added VC++ 2008 and VC++ 2010 solutions and projects to the code.
I organise my development code a little closer still to (to what I think is) the wxWidgets standard; so to fit in with my other code (particularly wxDatabaseConfig) I have to restructure wxDatabase further again. I will upload the restructured code shortly.
Not quite sure I understand your last post. "I'm now working with wxDatabase" and "I do not use it at all" seem contradictory!
Anyway, yesterday I downloaded your latest wxDatabase and merged my TDS and ODBC fixes and all the tests back into your code. In what I've put together we have MySql, PostGreSQL, Sqlite3, ODBC and TDS. I've run the tests for ODBC and TDS and they both pass all 65.
As I mentioned in an earlier post, I'm exclusively a VC++ developer on Windows so I've also added VC++ 2008 and VC++ 2010 solutions and projects to the code.
I organise my development code a little closer still to (to what I think is) the wxWidgets standard; so to fit in with my other code (particularly wxDatabaseConfig) I have to restructure wxDatabase further again. I will upload the restructured code shortly.
- Attachments
-
- wxDatabase.rar
- (172.54 KiB) Downloaded 257 times