From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 23E2C7EEF8 for ; Fri, 17 Jul 2015 09:10:56 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of paurkedal@gmail.com) identity=pra; client-ip=209.85.215.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="paurkedal@gmail.com"; x-sender="paurkedal@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of paurkedal@gmail.com designates 209.85.215.50 as permitted sender) identity=mailfrom; client-ip=209.85.215.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="paurkedal@gmail.com"; x-sender="paurkedal@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f50.google.com) identity=helo; client-ip=209.85.215.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="paurkedal@gmail.com"; x-sender="postmaster@mail-la0-f50.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AJBQByqahVmzLXVdFag2dpgyOtS4xthXUCgUhMAQEBAQEBEgEBAQEBBgsLCSEuQQSDXgEBAQMBEhEEGQEbHgMBCwYFGAICBRMOAgIPBQ8RAQUBV4d2AQMKCAQBCKtbgSw+MYs/gWyCeYtAChknDVeEVwEBAQEBAQQBAQEBARcBAQQOgRSKKoUNFoJSL4EUBZRNhG+HLQGBQ4Z4MY5NNYEVF4QNbYJLAQEB X-IPAS-Result: A0AJBQByqahVmzLXVdFag2dpgyOtS4xthXUCgUhMAQEBAQEBEgEBAQEBBgsLCSEuQQSDXgEBAQMBEhEEGQEbHgMBCwYFGAICBRMOAgIPBQ8RAQUBV4d2AQMKCAQBCKtbgSw+MYs/gWyCeYtAChknDVeEVwEBAQEBAQQBAQEBARcBAQQOgRSKKoUNFoJSL4EUBZRNhG+HLQGBQ4Z4MY5NNYEVF4QNbYJLAQEB X-IronPort-AV: E=Sophos;i="5.15,494,1432591200"; d="scan'208";a="170564455" Received: from mail-la0-f50.google.com ([209.85.215.50]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Jul 2015 09:10:55 +0200 Received: by lahh5 with SMTP id h5so56195640lah.2 for ; Fri, 17 Jul 2015 00:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=WZp1LyLYfXwHVBECzClgVaDIfQDazeezUibgO9N/W5Q=; b=Y5KWPGcYWIt91rtSADps5TaJucgT7Q5mWKc7nrL4pJHlYMiJ7KZ5Oc9ErWivnmkWEh uWAWYnSYRlcyGmf4n6uz0/3NfN0QIl33aUbAmH15F4jctdvrPNXWbBMU2SPINHtf20ms U0o7j4bQRGzt94oEvvTAaO3FU7i1mcG06vRZUUUTYl6f5pNWrACA8SfxK/iIAol+8ws/ XWYDdAlLVSr+E8606ZC/yCfcFyIOzMeI7+FzBxy1PfGsw6LwANmpqu2kI7kQOwSIj5S5 38xiQ4jz8OocS/Ku80pKm8m6MaA1oKGgx1O66p/dYsstUsefqt7ZNGzIW0PlKiY6CfcW 2AVQ== X-Received: by 10.112.168.165 with SMTP id zx5mr12843705lbb.111.1437117054859; Fri, 17 Jul 2015 00:10:54 -0700 (PDT) Received: from dione.int.eideticdew.org ([79.142.225.158]) by smtp.gmail.com with ESMTPSA id m7sm2157293laf.35.2015.07.17.00.10.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 17 Jul 2015 00:10:53 -0700 (PDT) Date: Fri, 17 Jul 2015 09:10:33 +0200 From: Petter Urkedal To: caml-list@inria.fr Message-ID: <20150717071033.GA12591@dione.int.eideticdew.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] looking for "real world" sqlite3 examples I have two projects which may also be of interest. I haven't announced them earlier, but I'm using them in almost production ready code: Caqti [1] is a common interface to database client libraries, currently supporting the postgresql and sqlite3 bindings. It supports monad-based cooperative threading, including lwt and async. MySQL/MariaDB and ODBC would be nice additions, but it would be preferable to have async bindings for these, to avoid resorting to preemptive threading. Caqti can be used directly (see e.g. [2]) though it does not provide a high-level type-safe interface. The high-level interface is omitted since I think there are different approaches depending on the problem and the programmer's taste, and it would be nice if the high-level interfaces used a common library to connect and communicate with the database. epiSQL [3] is a tool which parses SQL definitions and re-emits it as XML or generates code for Macaque or Caqti. On 2015-07-04, Martin DeMello wrote: > 1. database schema, versioning and migrations - will i need to do > those independently via sql/shell scripts, or is there some good way > to integrate them into my ocaml code? The Caqti_sql_utils module provides a function to read SQL statements from a file and sending them to the database. It's used in load_sql in [4]. Then one needs a schema version, and a function which iterates over DB updates from that version. I have though about adding something like that, but I'd like more experience in the end-application before moving code to Caqti. It would be nice to also have a developer tool to verify that the updates correspond to the changes in the schema. This would fit into epiSQL, but takes a bit though and work to implement. > 2. type conversions - in the absence of an orm, do i have to write my > own by hand per resultset. or is there some intermediate-level library > that i haven't found that would automate some of it? In Caqti you have to pass a function to extract fields from the returned tuple, as in `C.Tuple.(fun tup -> int 0 tup, text 1 tup)`, or when folding, `C.Tuple.(fun tup acc -> (int 0 tup, text 1 tup) :: acc)`. So, it does part of the job, but requires care due to the lack of type- and bounds-checks. [1] https://github.com/paurkedal/ocaml-caqti [2] https://github.com/paurkedal/subsocia/blob/master/lib/data/subsocia_direct.ml [3] https://github.com/paurkedal/episql [4] https://github.com/paurkedal/subsocia/blob/master/bin/subsocia_main.ml