Reviving DatabaseLayer

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
manyleaves
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue Mar 26, 2013 3:52 am

Re: Reviving DatabaseLayer

Post by manyleaves » Tue May 07, 2013 12:18 am

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.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Tue May 07, 2013 7:12 am

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.
Ah! I understand. It will be cool to have 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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Mon Oct 06, 2008 12:55 pm

Re: Reviving DatabaseLayer

Post by samsam598 » Wed May 08, 2013 8:28 am

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.
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
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;

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));
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=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 xp
VS.Net 2003/MinGW 3.4.5 C::B character set: UTF-8
wxWidgets github 3.0 RC1 Unicode Static build,Unicode Shared build.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Wed May 08, 2013 1:45 pm

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.
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
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;

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));
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=wxString::Format(wxT("insert into artists values(%d,'%s');"),7,wxT("待插入记录"));
     rowAffected=db.RunQuery(newRow,false);
     wxMessageBox(wxString::Format(wxT("%d row affected."),rowAffected));
Can you make a minimal app that I can use to test your case?
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Mon Oct 06, 2008 12:55 pm

Re: Reviving DatabaseLayer

Post by samsam598 » Thu May 09, 2013 12:44 am

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
Attachments
NewDBtest.7z
(23.42 KiB) Downloaded 164 times
Regards,
Sam
-------------------------------------------------------------------
Windows xp
VS.Net 2003/MinGW 3.4.5 C::B character set: UTF-8
wxWidgets github 3.0 RC1 Unicode Static build,Unicode Shared build.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Thu May 09, 2013 9:36 am

samsam598 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
Give me little time and I will test and find the issue and try to fix them
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Thu May 09, 2013 7:11 pm

evstevemd wrote:
samsam598 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
Give me little time and I will test and find the issue and try to fix them
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.
The Code just crashes with stupid error that I cannot understand, so I have to debug :x
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Mon Oct 06, 2008 12:55 pm

Re: Reviving DatabaseLayer

Post by samsam598 » Fri May 10, 2013 12:40 am

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
Attachments
NewDBtest.7z
(23.42 KiB) Downloaded 159 times
Regards,
Sam
-------------------------------------------------------------------
Windows xp
VS.Net 2003/MinGW 3.4.5 C::B character set: UTF-8
wxWidgets github 3.0 RC1 Unicode Static build,Unicode Shared build.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Fri May 10, 2013 7:49 am

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
How does GetColumnTypeName differ with GetColumnType?
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Mon Oct 06, 2008 12:55 pm

Re: Reviving DatabaseLayer

Post by samsam598 » Fri May 10, 2013 2:13 pm

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
Regards,
Sam
-------------------------------------------------------------------
Windows xp
VS.Net 2003/MinGW 3.4.5 C::B character set: UTF-8
wxWidgets github 3.0 RC1 Unicode Static build,Unicode Shared build.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Fri May 10, 2013 2:17 pm

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
I tried on Linux I could not get it work (its drivers are commercial. I will try to work it tomorrow on windows machine)
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 324
Joined: Mon Oct 06, 2008 12:55 pm

Re: Reviving DatabaseLayer

Post by samsam598 » Wed May 15, 2013 8:33 am

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.

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 xp
VS.Net 2003/MinGW 3.4.5 C::B character set: UTF-8
wxWidgets github 3.0 RC1 Unicode Static build,Unicode Shared build.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Wed May 15, 2013 8:42 am

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!
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Reviving DatabaseLayer

Post by evstevemd » Wed Jul 17, 2013 6:33 pm

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!
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?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

manyleaves
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue Mar 26, 2013 3:52 am

Re: Reviving DatabaseLayer

Post by manyleaves » Wed Aug 14, 2013 11:59 pm

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.
Attachments
wxDatabase.rar
(172.54 KiB) Downloaded 199 times

Post Reply