我正在做一个F#项目,需要对在线mysql数据库进行一些数据库查询.谁能帮帮我吗.我需要这样的东西
\\ Connect to DB
let servername = "localhost"
let username = "username"
let password = "password"
\\ Code that connects to db
\\ Print error message if can connect
\\ Query
let query = "SELECT * FROM table ..."
\\ Code that executes query
\\ Error Message if query not executed
解决方法:
您应该为MySQL安装.NET驱动程序.然后安装SQLprovider.在文档中有MySQL的示例.您将连接到数据库并像这样查询它:
type sql = SqlDataProvider<
dbVendor,
connString,
ResolutionPath = resPath,
IndividualsAmount = indivAmount,
UseOptionTypes = useOptTypes,
Owner = "HR"
>
let ctx = sql.GetDataContext()
let employees =
ctx.Hr.Employees
|> Seq.map (fun e -> e.ColumnValues |> Seq.toList)
|> Seq.toList
connstring将如下所示:
[]
let connString = "Server=localhost;Database=HR;User=root;Password=password"
标签:f,connect,sql,mysql,database
来源: https://codeday.me/bug/20191027/1941119.html