|
PowerBASIC Forums
![]() Source Code
![]() Embedded MySQL Server (Page 1)
|
This topic is 2 pages long: 1 2 |
next newest topic | next oldest topic |
| Author | Topic: Embedded MySQL Server |
|
Torben Marcussen Member |
Updated June 23, 2003
------------------ [This message has been edited by Torben Marcussen (edited June 22, 2003).] IP: Logged |
|
Torben Marcussen Member |
It seems the dll needs access to the error codes which can be found under the share directory in the mysql installation. Just grap the language of your choice and create a link to it in the serverOptions. EG:
------------------ IP: Logged |
|
jforgey unregistered |
This is great! does this mean I would just need the DLL and not the complete mySQL installation? Thanks Jason ------------------ IP: Logged |
|
Frederic Faure Member |
Thx much Torben for sharing this piece of code :-) However, it fails running because there's a mismatch in the mySQL_real_connect function: Declare Function mySQL_real_connect Lib "libmySQLd.DLL" Alias "mysql_real_connect" (ptMYSQL As T_MYSQL Ptr, szHostName As Asciiz,szUserName As Asciiz, szPassword As Asciiz,szDbName As Asciiz, ByVal lPortNum As Long,szSocketName As Asciiz, ByVal lFlags As Long) As Long [..] Function mySQL_Connect (dbName As Asciiz) As Dword Couple of questions: 1. Are some fields optional? I'm using PBWin 7, and it doesn't seem to allow calling a function with less parameters than set in the declaration. 2. What about performances over using the client-server version? Thx again ------------------ IP: Logged |
|
Frederic Faure Member |
Oops. I guess I got a different version of the MYSQL.INC file. The one above does have the right number of parameters. My bad :-) However, I get a GPF when PB calls mySQL_server_init() in mySQL_server_connect() using the 6 items that you added. I installed MySQL 4 for Windows, and copied C:\mysql\share\english\errmsg.txt as "english" where the PB EXE lives per your indications. Could that be the issue? Thx ------------------ IP: Logged |
|
Frederic Faure Member |
Solved by cheating, and using this: Dim lResult as LONG For information, the resulting file is located under C:\MYSQL\DATA\ (I had to install the C/S version to get the embedded version of MYSQL). I assume an entry in the Registry or some INI file somewhere tells MySQL where to save data. That issue will have to be resolved when using the embedded SQL. Also, the file is big : 10MB for just 10 fifty-character strings... but this might be optional ("030531 17:46:43 InnoDB: Setting file C:\mysql\data\ibdata1 size to 10 MB") Finally, you can compress the 2MB DLL to 800KB using the open-source UPX.EXE (http://upx.sourceforge.net Thx ------------------ IP: Logged |
|
Torben Marcussen Member |
Frederic, You must use the include file as I have provided for the code If you use mySQL_server_init(0,%NULL,%NULL) then the embedded server However, you can override this with the array of switches that For example: --datadir will specify the data directory and I think the problem you are having is because of the error messages. For those who are interested, here is the complete working example: Cheers ------------------ IP: Logged |
|
Frederic Faure Member |
Thx a bunch Torben :-) Indeed, I thought that I only had to copy the err msg file and As an aside, it's better to create a sub-directory eg. "./data/" Bottom line : Bah, I brushed up a bit on using pointers ;-) Wonder if I should Thx again. You've been of a great help ------------------ IP: Logged |
|
Bill Fletcher Member |
Addition to MySQL.inc to escape special characters in a string so it can be included in an SQL statement. It maps ASCII 0 13 10 onto \0 \n \r etc and encodes ' to \' . Any help getting BLOBs back out again would be greatly appreciated (see my posting in PB Win forum)! Bill
------------------ [This message has been edited by Bill Fletcher (edited June 19, 2003).] IP: Logged |
|
Torben Marcussen Member |
I have updated the above code to fix the type of the record field.... I have also changed the serverGroups to stop the program from Cheers ------------------ IP: Logged |
|
Bill Fletcher Member |
Just one more footnote before our friedly moderators slap a padlock on this thread. As written above mySQL_data() only retrieves the first column / field in a row. You have to read the offsets to the other fields as in the revised code below. Note that I have used 0-based indices (Torben used 1-based). Since binary data might contain Chr$(0)s I wrote a complementary function mySQL_binarydata() to read columns by length. I also re-typed two of the functions as DWord -- this may be the unnecessary paranoia of an amateur programmer. Again many thanks to Torben (and to Florent for his earlier examples) for an excellent interface to a very power DB engine. Bill ----------------------
[This message has been edited by Bill Fletcher (edited June 23, 2003).] IP: Logged |
|
David L Morris Member |
Hi Torben and others There must be something wrong with me as I cannot find how to download libmysqld.dll Can someone point me to the right location please? Regards David Monday June 30, 2003 I managed to get the libmysqld.dll by downloading the example from Torben's site URL Thanks again. [This message has been edited by David L Morris (edited June 29, 2003).] IP: Logged |
|
Torben Marcussen Member |
Hi David, The DLL is part of the complete MySql package that you download Or, you can just click on the link to my example a couple of Cheers ------------------ IP: Logged |
|
David L Morris Member |
Thanks Torben. My intro to MySQL was last weekend in Sydney, when I spotted a $14.95 book in the news agent "Introduction to MySQL" which included a CD. I was very impressed and recalled your posting in this forum. Hence, I am on my way. Incidently, are you in Australia? Regards David ------------------ IP: Logged |
|
Stein Oiestad Member |
quote: I don't think the link above is working anymore. Does anyone have Thanks -stein ------------------ IP: Logged |
This topic is 2 pages long: 1 2 All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.