Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:08:51+00:00 2026-06-11T04:08:51+00:00

I have a large database (approx. 150 000 records) that I want to embed

  • 0

I have a large database (approx. 150 000 records) that I want to embed into an OCaml source code named compute.ml. I am trying (without success) to transform these tables into hashtables and to embed these hastables into a function compute, so as to have the binary program run quicly without having to do queries to an external sql database.

I have 2 questions:

  • Is there a way to export for once a mysql table into an associative array (Hashtbl) that can be accessed by (or even embedded into) my OCaml function compute (itself compiled and used as a binary)?
  • Is this hashtable permanently loaded in the function or has it to be re-initiated each time that the function is called within the binary?

I have a mysql table with 142741 records which, exported in CSV format, looks like this:

"1";"27";"10";"coco";"0";"730";"1641025";"1641053";"foo";"1";"S";"0"
"2";"27";"11";"kiki";"0";"730";"1641054";"1641083";"bar";"1";"S";"0"
"3";"27";"12";"toto";"0";"730";"1641084";"1641113";"foofoo";"1";"S";"0"
"4";"27";"1";"tata";"0";"730";"1641114";"1641142";"barbar";"1";"S";"0"
...
"142741";"5";"7";"chotto";"0";"1347";"1971472";"1971500";"lastrecord";"1";"S";"0"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:08:53+00:00Added an answer on June 11, 2026 at 4:08 am

    I would have a .csv file data.csv containing your mysql table, exported to csv format.
    Then in OCaml, I would read and parse this file, once, when the program is launched:

    let data = read_csv("data.csv")
    

    data is thus a variable, of type Hashtbl.t, containing your 150K records.
    Then, an OCaml function (which is called compute in your question) uses this variable:

    let compute x =
      let foo = Hashtbl.find data x in
      ...
    

    This way, there are no calls to a MySQL server, the data is read only once when you launch the program, and then each call to the function compute uses the already in memory variable data.

    If you’re concerned about reading and parsing the csv file, you might have a look at the Marshal module, to store a binary version of the variable data.

    Note that read_csv is not in the standard library, but there is for instance http://csv.forge.ocamlcore.org/ .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large database with over 150 tables that I've recently been handed.
i have a large MYSQL database with hundreds of thousands of records. i want
I have a large Oracle database ( 720,000 records aprox) where each record has
I have a large database of users (~200,000) that I'm transferring from a ASP.NET
I have a large database which contains records that have <a> tags in them
I have a large database, devDB that I want to duplicate on the same
I have a large database table that I need to display on a Windows
Here is the main problem. I have very large database (25,000 or so) of
I have a very large database with about 120 Million records in one table.I
I have a very large database (~100Gb) primarily consisting of two tables I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.