Created
June 29, 2019 15:15
-
-
Save pizycki/55235a3b652a243d7d85483e6f20f688 to your computer and use it in GitHub Desktop.
MySQL, Dapper and F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place this in .fsproj | |
// <ItemGroup> | |
// <PackageReference Include="Dapper.Contrib" Version="1.60.1" /> | |
// <PackageReference Include="MySqlConnector" Version="0.56.0" /> | |
// </ItemGroup> | |
open Dapper | |
open MySql.Data.MySqlClient | |
// CREATE TABLE `8833_rw_dev`.`Releases` ( | |
// `MovieTitle` VARCHAR(200) NULL); | |
[<CLIMutable>] | |
type ReleaseRow = | |
{ | |
Id: int | |
MovieTitle: string | |
} | |
[<EntryPoint>] | |
let main argv = | |
let connString = "server=mysql-server;uid=user;pwd=*******;database=db" | |
let dbConn: MySqlConnection = new MySqlConnection(connString) | |
let sql = "SELECT * FROM Releases" | |
let rows = dbConn.Query<ReleaseRow>(sql) | |
for r in rows do | |
printfn "%O" r | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment