A library to generate models from a database?

I am looking for a library to generate OCaml models from a database

I found this library for mysql: https://github.com/pat227/ocaml-db-model
(have not tested it)

but am searching if there is anything for postgre?

(if not, this is so essential that I would rather switch to using mysql than writing models by hand)

1 Like

Hi @mudrz,

I don’t know what you’re building but I just wanted to make you aware that the repo you’re linking to is licensed under GPL without a linking exception. This means that if you redistribute your application you must also make all your source code available. Just wanted to make sure you know before you start using it.

3 Likes

Indeed, and looks like it’s GPLv3, meaning it doesn’t have the ‘TiVo loophole’, i.e. you have to make the source code available even if you provide the application as a service online, without distributing it to end users.

You’re confusing with the AGPL, that’s not the tivo loophole.
The Tivo loophole, which is blocked by GPL3, is “ship a locked down device to users, so even though they can get source code it’s useless to them”, ie there is “distributing it to end users”.

2 Likes

Thanks for the correction.

hmm, that’s a pretty important detail that I have missed;
hey @papatango is the library license intentional?

As to Postgresql, I actually had long meant to get around to supporting postgresql and just did very recently. Before I read your message, btw.

I consider these to be very rough around the edges, but the big fat middle of use cases are covered and I think most users would be satisfied. I know I am when I can skip writing tons of modules by hand. But of course, there is room for improvement. Some of the less commonly used data-types are not supported, for example. Building is a bit of a PIA but I have used dune successfully to create modules on the fly based on database tables. Extending modules (include module foo) is your friend for customizing modules in conjunction with the use of the (include subdirs unqualified) directive to dune in your project.

As to the license, yes I did intend to use that license. Why is that license a problem for you? What use case do you foresee that is precluded by it? I’m no expert on licensing and I had never heard of the tivo loophole until I read this thread. I suppose I could review the licensing options available to me but I’ve only heard good things about GPLv3.

2 Likes

Btw, speaking of data types, I noticed you are using Bignum to map DECIMAL type; now that Jane Street has open sourced Bigdecimal, you may want to consider using that: OCaml needs an arbitrary-precision decimal type

Absolutely. I noticed that too recently. Thx.

1 Like

Hi @papatango!

First of all thanks for sharing your work, greatly appreciated!

As to the license, yes I did intend to use that license. Why is that license a problem for you? What use case do you foresee that is precluded by it? I’m no expert on licensing and I had never heard of the tivo loophole until I read this thread. I suppose I could review the licensing options available to me but I’ve only heard good things about GPLv3.

What follows here are my thoughts and opinions and by no means do you need to agree with them.

While I can’t speak for @mudrz I can see a problem with a GPL licensed library from a company’s perspective as including such a library would force them to release their entire application as open source. While there are companies who have successfully built businesses around open source software one could argue that it is a double-edged sword. In a hypothetical scenario where I’m running my own business I would be very hesitant to open source my product before having built a solid customer base and even then I would be second guessing that decision. For more details around what potential issues one might run into when open sourcing their product I would suggest reading up on the struggle that Timescale and MongoDB went through.

From the main author’s perspective I totally respect your right to do what you want with your software however I’m assuming that since you decided to share it on Github that you would want others to use and take advantage of your efforts. From this point of view GPL might also be an issue since it will scare most (all?) companies away from using it. This might lead them to develop their own alternative and license it under LGPL, MIT or the Apache license which all are more business friendly while still forcing any modifications to be available.

I would strongly encourage you to not listen blindly to what I said above and instead read up on the matter yourself. Here are some resources to get you started:

I’m going to end this post with a quote from the GPL:

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
https://www.gnu.org/licenses/why-not-lgpl.html.

3 Likes

Apologies in advance for taking this thread off-track, but:

In a hypothetical scenario where I’m running my own business I would be very hesitant to open source my product before having built a solid customer base and even then I would be second guessing that decision. For more details around what potential issues one might run into when open sourcing their product I would suggest reading up on the struggle that Timescale and MongoDB went through.

If I understand correctly these companies went through these issues partly based on the fact that they originally had very permissive licenses. With the GPLv3, that would be less of a concern. In fact, Mongo even says, in the FAQ you linked to, that their new license is based on GPLv3.

From this point of view GPL might also be an issue since it will scare most (all?) companies away from using it.

This might actually be a desirable outcome :wink: Seriously though, if any company genuinely wants to use this library, they will do what any reasonable company would, and ask the author to sell them a commercial use license.

This might lead them to develop their own alternative and license it under LGPL, MIT or the Apache license which all are more business friendly while still forcing any modifications to be available.

Unfortunately for the OCaml community, till date we have not exactly seen companies busting down the door to publish libraries (with a few notable exceptions of course). It could even be argued that companies actually paying attention to and participating in the OCaml ecosystem could only be a good thing, and if the author of this library played any part in making that happen, I would just have to say, hats off to them!

1 Like

hi Paul, thanks for these libraries!
And thanks to Robin for the summary and helpful links.
My concerns with GPL and potential user are (and feel free to ignore these of course :slight_smile: ):

  • GPL forces you to open source any software that uses work with this license. That’s not always viable or practical. It’s an issue for small developers - imagine implementing a web app for a client - would the client be okay to open source their web app? is it practical to ask each library author whether they are okay not to open source a particular application? and is a potential issue for larger companies, so they just end up with in-house implementation of gpl libraries
  • it is an issue for derivative open source libraries since those now also have to impose the same restrictions and be subject to the same limited use
  • it is an issue even for hobby projects since work from these cannot then be propagated to commercial work

I think these are some of the reasons why even the linked examples like jOOQ https://github.com/jOOQ/jOOQ/blob/main/LICENSE and Microsoft’s Entity Framework https://github.com/dotnet/efcore/blob/main/LICENSE.txt use Apache, JaneStreet’s libraries (including the linked BigDecimal library) use MIT.

My personal situation is that I am currently evaluating OCaml for use for web apps development (together with F# and TypeScript) and am gathering and checking if it has all the much needed bits and pieces. I am not running a business and the company I work for does not use OCaml. I am not an active contributor to OCaml libraries since I am not an active user of OCaml. But speaking from the perspective of someone that is considering joining the ecosystem - GPL licenses are a major blocker.

@yawaramin I think the issue with the limited selection of libraries in OCaml is not companies fearing to share their work, but the size of the community and GPL (and LGPL to a lesser extent) is certainly not the solution to that (especially if more permissive alternatives exist in the other communities) :slight_smile:

these are my opinions of course, as someone that doesn’t considers himself a part of the community yet, and they might be very different from others

3 Likes

Mudrz, I know that :slight_smile: Note, I didn’t say companies ‘fear’ to share their work, I said they’re not exactly breaking down the doors to participate in the OCaml community. Companies in general are risk-averse and reluctant to adopt anything outside the mainstream.

All that to say, I think people using GPL or not for their small libraries is not going to influence these companies one way or the other.

Again, no expert here, but it seems to me that the GPL v3 license is the best license for my purposes. I understand why someone else might not want to be restricted by the GPL v3, however. I would recommend to said persons that they request a written commercial license if in fact they have a profitable use in mind. Throw me a bone. Or a job offer. Collaboration could be fun.

There might be a possible usage scenario where the license doesn’t affect your entire project and makes all this moot. I did write these with command line use in mind, before compile-time, in other projects. So even though my project would be a dependency, you don’t even have to link to anything and it’s a totally separate process. The output of my program is obviously not copyrighted but yours.

See:
https://www.gnu.org/licenses/gpl-faq.en.html

However, in many cases you can distribute the GPL-covered software alongside your proprietary system. To do this validly, you must make sure that the free and nonfree programs communicate at arms length, that they are not combined in a way that would make them effectively a single program.

8 Likes

See also:

A command line dependency does not restrict your choice of license or being closed source. Hopefully that is sufficient for your intended use.

1 Like

thanks papatango, to clarify - I respect the choice of license, I just provide my perspective

In a company, that has new people joining, it is more practical to simply not use GPL libraries, than to train newcomers and worry about people using the libraries “at arms length”

EDIT: since the licenses is a good discussion, I created a new topic LGPL licenses handling in OCaml

I don’t quite understand this part–obviously it can, it’s source code–maybe you mean that linking in the same binary virally spreads the LGPL license to the rest of the binary? I don’t think that’s correct either, as the LGPL has the linking exception.

what I mean is that per the shared link - if it is statically linked the whole binary needs to fall under the same license; it could be a different situation for a web app since users can’t “replace” library versions anyways

@mudrz Interesting discussion on licenses. I have to read up on the LGPL. Perhaps we could compromise there after I do more research and reconsideration.

A web app, btw, doesn’t sound like an application for which source code distribution is required even if subject to GPLv3 since the software itself in binary form is not being distributed to users, they merely interact with it.

I realize JOOQ and Jane Street use very permissive licenses, but ODB for C++ does not. Is ODB the standard for this task in the world of C++? (https://www.codesynthesis.com/products/odb/license.xhtml) Does anyone know? Or know why they use GPLv2, with lots of exceptions detailed on the page?

1 Like