All Projects → ryantm → Hdbc Mysql

ryantm / Hdbc Mysql

Licence: lgpl-2.1
This package provides a MySQL driver for Haskell's HDBC library, implemented via bindings to the C mysqlclient library.

Programming Languages

haskell
3896 projects

Labels

Projects that are alternatives of or similar to Hdbc Mysql

Cuprite
Headless Chrome/Chromium driver for Capybara
Stars: ✭ 743 (+2462.07%)
Mutual labels:  driver
Yubihsm Go
A Go client for the yubihsm2 binary protocol and connector service
Stars: ✭ 19 (-34.48%)
Mutual labels:  driver
Cycle Idb
A cycle driver for IndexedDB.
Stars: ✭ 12 (-58.62%)
Mutual labels:  driver
Displaylink Debian
DisplayLink driver installer for Debian and Ubuntu based Linux distributions.
Stars: ✭ 768 (+2548.28%)
Mutual labels:  driver
Vsphere Modules
This is my Module Collection for VMware vSphere
Stars: ✭ 18 (-37.93%)
Mutual labels:  driver
Hyperplatform
Intel VT-x based hypervisor aiming to provide a thin VM-exit filtering platform on Windows.
Stars: ✭ 925 (+3089.66%)
Mutual labels:  driver
Neo4j Javascript Driver
Neo4j Bolt driver for JavaScript
Stars: ✭ 674 (+2224.14%)
Mutual labels:  driver
Rust Uefi Runtime Driver
Template for UEFI runtime drivers written in Rust with serial logging and debugging support.
Stars: ✭ 21 (-27.59%)
Mutual labels:  driver
Node Ntfs
Windows NT File System (NTFS) file system driver
Stars: ✭ 18 (-37.93%)
Mutual labels:  driver
Openhmd
Free and Open Source API and drivers for immersive technology.
Stars: ✭ 837 (+2786.21%)
Mutual labels:  driver
Mongo Cxx Driver
C++ Driver for MongoDB
Stars: ✭ 792 (+2631.03%)
Mutual labels:  driver
Adldap2 Laravel
LDAP Authentication & Management for Laravel
Stars: ✭ 825 (+2744.83%)
Mutual labels:  driver
Apfs Fuse
FUSE driver for APFS (Apple File System)
Stars: ✭ 929 (+3103.45%)
Mutual labels:  driver
Hidden
Windows driver with usermode interface which can hide objects of file-system and registry, protect processes and etc
Stars: ✭ 768 (+2548.28%)
Mutual labels:  driver
Awesome Android Things
A curated list of awesome android things tutorials, libraries and much more at one place
Stars: ✭ 883 (+2944.83%)
Mutual labels:  driver
Vigembus
Windows kernel-mode driver emulating well-known USB game controllers.
Stars: ✭ 721 (+2386.21%)
Mutual labels:  driver
Ruby I2c Devices
i2c-devices is a library for using I2C devices by using /dev/i2c-* or /sys/class/gpio with bit-banging.
Stars: ✭ 23 (-20.69%)
Mutual labels:  driver
Ds4 driver
DualShock 4 driver for ROS
Stars: ✭ 28 (-3.45%)
Mutual labels:  driver
Adfilter
This is a ad filter software using dns based on tdifw
Stars: ✭ 15 (-48.28%)
Mutual labels:  driver
Tabletdriver
TabletDriver Download: http://hwk.fi/TabletDriver/TabletDriverV0.2.3.zip
Stars: ✭ 936 (+3127.59%)
Mutual labels:  driver

HDBC-mysql

This is a "native" HDBC driver for MySQL that makes use of libmysqlclient to communicate with a MySQL server. By way of synopsis:

import Control.Monad
import Database.HDBC
import Database.HDBC.MySQL
main = do conn <- connectMySQL defaultMySQLConnectInfo {
                       mysqlHost     = "db1.example.com",
                       mysqlUser     = "scott",
                       mysqlPassword = "tiger"
                    }

          rows <- quickQuery' conn "SELECT 1 + 1" []
          forM_ rows $ \row -> putStrLn $ show row

At the moment, please consider this to be "alpha" software. As far as I can tell, it works. There are some limitations that you should be aware of.

Caveats

  • This works with MySQL server and client libraries 5.0.75. I haven't tried with 4.x nor 5.1. I suspect that using a server version less than 4.1 won't work, due to lack of support for prepared statements.

  • MySQL DATETIME and TIMESTAMP columns have no time zone information, because they just don't. So, I'm just converting them blindly to SqlEpochTime values, and assuming the times are UTC. This is all fine if you're actually running your server in UTC, but it will probably be confusing if you're not. It might be possible to interpret the times using the current connection's default time zone setting, instead. Is that better? Or worse?

  • Regardless, the types I convert to are now deprecated, and I need to implement the new types (SqlLocalDate, etc.)

  • Out of the box, MySQL probably uses MyISAM tables to store its data, and MyISAM tables don't support transactions. Yet, I'm going to blindly respond "yes" if you ask whether the driver itself supports transactions, and assume that you know enough to use InnoDB tables in the database if you want to make use of HDBC's transactional support. I suppose I might be able to discover what the default table type is, and say "no" if it's not a table type that supports transactions, but... meh.

  • I'm not sure that I can tell the difference between a MySQL TEXT and a MySQL BLOB column. If you ask about the metadata of either, I'll tell you it's a SqlBinaryT.

  • The statement and table metadata could stand to be improved a bit. In particular, it would be nice if "describeTable foo" and "describeResults" on "SELECT * FROM foo" returned the same thing. (They're sorta close, I guess...)

  • Thread-safety could be an issue. In the driver code, there's definitely a race condition between "prepare" and "disconnect", for example. I haven't even looked at thread-safety issues for the MySQL driver. I'm not sure if I should worry about it, or if we assume that's going to be dealt with at a higher level.

  • We might crash if someone opens a connection, prepares a statement, explicitly disconnects the connection, and then tries to play with the statement.

  • It probably makes sense to marshall to the SqlByteString type when retrieving BLOB data.

Testing

There's a little test program that runs a query and spews out the results. To compile it,

ghc -idist/build -L/opt/local/lib/mysql5/mysql -lmysqlclient --make Test

I'm still trying to get the Makefile right so that it can build the test sources: it's not there yet. Here's how I've been doing it, for now:

cd testsrc
ghc --make -package HUnit -package HDBC -Wall -i../dist/build -i.. -L/opt/local/lib/mysql5/mysql -lmysqlclient -o runtests runtests.hs

One issue is that I want the location of the MySQL library to come from the configuration data, rather than be hard-coded.

Developing hdbc-mysql with nix

# Nix shell
nix-shell -p haskell.packages.ghc801.ghc gcc mysql57 pkgconfig zlib openssl haskellPackages.haddock

# Use Cabal to build
cabal clean && cabal build

# Build test script
ghc -idist/build -L/nix/store/vksgj509kdnk3rva0x64qwp21nzrxy9b-mariadb-10.1.16/lib -lmysqlclient --make Test

# Run test script
./Test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].