# mysql insert set problem

I need some help.

set = {0, 0};
Print[set];
Needs["DatabaseLink"];
JDBCDrivers["MySQL(Connector/J)"]
conn = OpenSQLConnection[
JDBC["MySQL(Connector/J)", "localhost:3306/test"],
SQLExecute[conn, "INSERT INTO numbers VALUES ([set]) "]


I don't know know how to escape [set] in the insert statement

In the database the field type is text

-
set = {11, 2, 3}; -> i have modified as you suggested, now the problem is that only the first number 11 of the set is inserted -> SQLExecute[conn, "INSERT INTO numbers (text) VALUES (1) ", set] –  user5356 Jan 10 '13 at 21:14
i want to put the entire set in one field of the db table, not one colum -> one element of set / from doc : SQLExecute[conn, "INSERT INTO TEST (X,Y) VALUES (1, 2)", {5, 2.1}] it's my first time using mathematica –  user5356 Jan 10 '13 at 21:24

You can use this:

set = {{0, 0},{1,1},{2,2}}
SQLExecute[conn,"INSERT INTO numbers VALUES (?,?)", set]


If you want to do just one case, use:

 set = {{0, 0}}


The ? way is the fast one.

You can lear a lot in the Database Link User Guide Tutorial that is a nice official material from Wolfram. You can download the pdf for free.

-
how can i put the entire set as "{{0, 0},{1,1},{2,2}}" in one field in the db with brackets so when i make a select the result returned to be -> {{0, 0},{1,1},{2,2}} ? –  user5356 Jan 10 '13 at 21:50
SQLExecute[conn,"INSERT INTO numbers VALUES (?,?)", set] –  user5356 Jan 10 '13 at 22:12
so i'm trying to reformulate, i have set = {{0, 0},{1,1},{2,2}} and a table with 3 fileds text1, text2, text3 , how can i put in the db the folwooing text1 -> {0, 0} , text2 -> {1, 1}, text3 -> {3, 3} ? –  user5356 Jan 10 '13 at 22:23
@user5356 You can handle it as a string, and use ToExpression to back it to MMA form again, like: ToExpression["{0,0}"]` you get {0,0} –  Murta Jan 10 '13 at 22:25
can you pls modify the query with ToExpression because i don't understand how to do that , tx –  user5356 Jan 10 '13 at 22:33