在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):winterland1989/mysql-haskell开源软件地址(OpenSource Url):https://github.com/winterland1989/mysql-haskell开源编程语言(OpenSource Language):Haskell 89.8%开源软件介绍(OpenSource Introduction):mysql-haskell
Is it fast?In short, Above figures showed the time to:
The benchmarks are run by my MacBook Pro 13' 2015. MotivationWhile MySQL may not be the most advanced sql database, it's widely used among China companies, including but not limited to Baidu, Alibaba, Tecent etc., but haskell's MySQL support is not ideal, we only have a very basic MySQL binding written by Bryan O'Sullivan, and some higher level wrapper built on it, which have some problems:
GuideThe {-# LANGUAGE OverloadedStrings #-}
module Main where
import Database.MySQL.Base
import qualified System.IO.Streams as Streams
main :: IO ()
main = do
conn <- connect
defaultConnectInfo {ciUser = "username", ciPassword = "password", ciDatabase = "dbname"}
(defs, is) <- query_ conn "SELECT * FROM some_table"
print =<< Streams.toList is
It's recommanded to use prepared statement to improve query speed: ...
s <- prepareStmt conn "SELECT * FROM some_table where person_age > ?"
...
(defs, is) <- queryStmt conn s [MySQLInt32U 18]
... If you want to do batch inserting/deleting/updating, you can use The {-# LANGUAGE LambdaCase #-}
module Main where
import Control.Monad (forever)
import qualified Database.MySQL.BinLog as MySQL
import qualified System.IO.Streams as Streams
main :: IO ()
main = do
conn <- MySQL.connect
MySQL.defaultConnectInfo
{ MySQL.ciUser = "username"
, MySQL.ciPassword = "password"
, MySQL.ciDatabase = "dbname"
}
MySQL.getLastBinLogTracker conn >>= \ case
Just tracker -> do
es <- MySQL.decodeRowBinLogEvent =<< MySQL.dumpBinLog conn 1024 tracker False
forever $ do
Streams.read es >>= \ case
Just v -> print v
Nothing -> return ()
Nothing -> error "can't get latest binlog position" Build Test BenchmarkJust use the old way: git clone https://github.com/winterland1989/mysql-haskell.git
cd mysql-haskell
cabal install --enable-tests --only-dependencies
cabal build Running tests require:
mysql -u root -e "CREATE DATABASE IF NOT EXISTS testMySQLHaskell;"
mysql -u root -e "CREATE USER 'testMySQLHaskell'@'localhost' IDENTIFIED BY ''"
mysql -u root -e "GRANT ALL PRIVILEGES ON testMySQLHaskell.* TO 'testMySQLHaskell'@'localhost'"
mysql -u root -e "FLUSH PRIVILEGES"
mysql -u root -e "GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'testMySQLHaskell'@'localhost';"
New features will be automatically tested by inspecting MySQL server's version, travis is keeping an eye on following combinations:
Please reference Enter benchmark directory and run
With ReferenceMySQL official site provided intensive document, but without following project, LicenseCopyright (c) 2016, winterland1989 All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论