Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
MySQL-Driver Status: integrated into 2.0b!
Another useful thing (with a different scope than the gdbm-driver) would be a MySQL-driver. Here is a smalltalk MySQL-driver available at: http://jdmsoft.com/MysqlDriver.html. It is reengineered from the c-source of the native MySQL-client lib, so it has no need for bindings.
I tried to work with the squeak version of the driver, but I needed too much code from squeak, so I decided to start from the original driver by Josh Miller. Here they are:
Mysql-Driver.st (VisualWorks 3.0 Version)
Mysql-Driver-Tests.st (VisualWorks 3.0 Version)
Testing-Framework.st (VisualWorks 3.0 Version)
Here is my first working version. Unpack it, then adjust the parameters in mysql-test.st. Then run it with
gst -Q mysql-test.st
The hardest translation was done in JdmWriteStream (look below). The rest was relatively simple (Adjusting socket-methods, conversion from ByteStream to Integer, etc). An impressive example for smalltalk's power!
!JdmWriteStream methodsFor: 'accessing'!
position _ (aPosition > writeLimit
ifFalse: [aPosition])! !"
"here's the trick involved:"
ptr := aPosition + 1! !
Here is a simple testscript:
| value resultSet statement spec connection |
FileStream fileIn: 'DB.st'.
FileStream fileIn: 'MySQL.st'.
spec := (Jdm JdmConnectionSpec new initialize
user: 'root'; password: ;
connection := Jdm MySQL JdmConnection on: spec.
statement := connection createStatement.
resultSet := (statement executeQuery: 'select * from db') value.
Transcript cr; show: (resultSet columns collect: [:col | col name]) printString
value := resultSet valueNamed: 'Db'. "get column named Db"
Transcript cr; show: value printString.
The hierarchy has been refactored with respect to the original driver by Josh. His initials now are the acronym for `Just a Database Manager', so the DBMS-independent classes have been moved to the `Jdm' namespace, while the MySQL driver proper resides in `Jdm MySQL'.
Markus Fritsche and Paolo Bonzini