How to access an English-Chinese dictionary database file correctly?



Now I have an English-Chinese dictionary database file (This database source file comes from this website and this file can be downloaded by clicking "点此下载". After downloading, you can rename it). I want to find out all the words whose second letter is b. But I don't know how to access this database file:

conn = OpenSQLConnection[JDBC["SQLite", "英语单词词典数据库 mysql版.sql"], 
  "Location" -> "C:\\Users\\Administrator\\Desktop", 
  "RelativePath" -> True]

But the above code is invalid, I very much hope that you can provide as detailed help as possible, what should I do?

A little mouse on the pampas

Posted 2021-01-13T08:49:24.797

Reputation: 4 904



This SQL file is not a sqlite3 database file. I don't know whether Wolfram Mathematica includes a complete MySQL program. I installed the latest version of MariaDB/MySQL on my computer.

1. Install MariaDB/MySQL

To access this database file, you may need to install MySQL/MariaDB. Then you need to start the MySQL process and import the SQL file to MySQL.

In short, you need to run the following commands in the terminal,

> mysql -uroot -p 
MariaDB [(none)]> create database dictionary;
MariaDB [(none)]> use dictionary;
MariaDB [(dictionary)]> source ./words.sql

2. Link MySQL

Next, you need to link MySQL at Mathematica.

conn = OpenSQLConnection[
  JDBC["MySQL(Connector/J)", "jdbc:mysql://localhost/dictionary"], 
  "Username" -> "root", "Password" -> "$Prompt"]

If everything is ok, then you can now query.

      "select cn from words where en='" <> # <> "'"]} & /@ {"is", 
   "here", "my"}, Frame -> All]

And results as follows,

enter image description here

Note: If you are using MySQL for the first time, you may need to reset the password. The relevant methods can be easily retrieved on the Internet.

J.W Kang

Posted 2021-01-13T08:49:24.797

Reputation: 378

1Thanks for providing this answer! – Anton Antonov – 2021-01-17T19:38:44.413


(Not an answer, or a partial answer.)

  1. I am not sure how many people would be willing / prepared to click on buttons on a site with language they do not understand. I think using GitHub repositories like this one is better.

  2. I get that the question is about DatabaseLink and SQL querying, but I assume getting the words is the primary goal.

  3. Can a CSV file be used instead?

  4. The correct SELECT SQL statement is: SELECT word FROM EnWords WHERE word LIKE '_b%'

  5. (I tried to import some English-Chinese SQL files into a local database, but have little success so far.)

Getting the words from a GitHub hosted CSV file

 dsEnglishChinese = 


RandomSample[dsEnglishChinese, 6]

dsEnglishChinese[Select[StringMatchQ[#word, LetterCharacter ~~ "b" ~~ __] &]]

enter image description here

Anton Antonov

Posted 2021-01-13T08:49:24.797

Reputation: 32 565