English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
ANN: OCaml/Sqlite ORM layer (preview 0.2)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-06-02 (17:20)
From: Anil Madhavapeddy <anil@r...>
Subject: ANN: OCaml/Sqlite ORM layer (preview 0.2)
I've been using OCaml in a few server projects which need a light- 
weight database, and so I wrote a library to map OCaml objects  
directly to a SQLite3 backend database.

Like other ORM systems, you define a schema based on sets of named  
fields.  The Sql_orm library then generates an OCaml module and  
interface with static accessor methods which take care of all the  
tedious SQL interactions and provide you with a nice high-level,  
statically type-safe access method.

It's still early days but the library is very functional and stable.   
I've put up docs and instructions at:

It's currently written as a module which outputs OCaml directly, and  
once I'm happy with the feature-set, I intend to port it to use camlp4  
so that schemas can be declared directly without the need to  
regenerate a separate ML file.

You can view an example schema at: http://tinyurl.com/sqlorm-example
- schema.ml declares the fields
- test.ml uses it
- my_db.* are the generated files.
- the tests/ directory has more advanced usage, such as foreign keys  
and so on.