Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
20a38bb4
Commit
20a38bb4
authored
11 years ago
by
ocelot-inc
Browse files
Options
Downloads
Patches
Plain Diff
plugins.xml changed mysql example
parent
ad27e342
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/user/plugins.xml
+42
-18
42 additions, 18 deletions
doc/user/plugins.xml
with
42 additions
and
18 deletions
doc/user/plugins.xml
+
42
−
18
View file @
20a38bb4
...
...
@@ -72,9 +72,10 @@ OK
OK
# Check that the mysql client can connect using some factory defaults:
# port = 3306, user = 'root', user password = '', database = 'test'.
# port = 3306, user = 'root', user password = 'root', database = 'test'.
# (Do not use a blank password.)
# These can be changed, provided one changes them in all places.
<prompt>
$
</prompt><userinput>
~/mysql-5.5/bin/mysql --port=3306 -h 127.0.0.1 --user=root --database=test
</userinput>
<prompt>
$
</prompt><userinput>
~/mysql-5.5/bin/mysql --port=3306 -h 127.0.0.1 --user=root
--password=root
--database=test
</userinput>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.5.35 MySQL Community Server (GPL)
...
...
@@ -111,6 +112,7 @@ Bye
<prompt>
$
</prompt><userinput>
make
</userinput>
...
[ 49%] Built target core
Scanning dependencies of target mysql
[ 50%] Building CXX object src/plugin/mysql/CMakeFiles/mysql.dir/mysql.cc.o
Linking CXX shared library libmysql.so
[ 50%] Built target mysql
...
...
@@ -119,17 +121,42 @@ Linking CXX shared library libmysql.so
[100%] Built target man
<prompt>
$
</prompt>
# Before starting Tarantool server, tell it where the MySQL plugin is.
<prompt>
$
</prompt><userinput>
export TARANTOOL_PLUGIN_DIR=~/tarantool-stable/src/plugin/mysql
</userinput>
<prompt>
$
</prompt>
# The MySQL module should now be in ./src/module/mysql/mysql.so.
# If a "make install" had been done, then mysql.so would be in a
# different place, for example /usr/local/lib/tarantool/1.5/box/net/mysql.so.
# In that case there should be additional cmake options such as
# -DCMAKE_INSTALL_LIBDIR and -DCMAKE_INSTALL_PREFIX.
# For this example we assume that "make install" is not done.
# Change directory to a directory which contains the tarantool.cfg file.
# For this example we assume that the name of this directory is
# /home/pgulutzan/tarantool_test. (Change "/home/pgulutzan" to whatever
# is the actual base directory for the machine that's used for this test.)
# Edit the tarantool.cfg file and add this line:
# script_dir = "/home/pgulutzan/tarantool_test"
# The script_dir is the directory where the init.lua file must be.
# Now create a file named /home/pgulutzan/tarantool_test/init.lua
# and put the following lines in it (again, change "/home/pgulutzan"
# to whatever the real directory is that contains tarantool-stable):
package.path = "/home/pgulutzan/tarantool-stable/src/module/sql/?.lua;"..package.path
require("sql")
if type(box.net.sql) ~= "table" then
error("net.sql load failed")
end
require("box.net.mysql")
# Now, to help tarantool_box find the essential mysql.so file, execute these lines:
<userinput>
cd /home/pgulutzan/tarantool_test
</userinput>
<userinput>
mkdir box
</userinput>
<userinput>
mkdir box/net
</userinput>
<userinput>
cp ~/tarantool-stable/src/module/mysql/mysql.so ./box/net/mysql.so
</userinput>
# Start the Tarantool server.
# Run it in the background but let the initial display be in the foreground.
# So it's possible to see the message that the plugin was loaded.
<prompt>
$
</prompt><userinput>
~/tarantool-stable/src/box/tarantool_box
&
</userinput>
2013-12-03 17:46:16.239 [12957] 1/sched C
>
version 1.5.1-271-g610930e
... Loading plugin: ~/tarantool-stable/src/plugin/mysql/libmysql.so ...
... Plugin 'mysql' was loaded, version: 1
... loading /home/pgulutzan/tarantool_test/init.lua ...
...
2013-12-03 17:46:16.244 [12957] 1/sched C
>
entering event loop
...
...
@@ -137,25 +164,20 @@ Linking CXX shared library libmysql.so
<prompt>
$
</prompt><userinput>
~/tarantool-stable/client/tarantool/tarantool
</userinput>
<prompt>
localhost
>
</prompt>
# Say
<quote>
show plugins
</quote>
. Since all has gone well, this is certain to work.
<prompt>
localhost
>
</prompt>
<userinput>
show plugins
</userinput>
---
plugins:
- { name: "mysql", version: 1 }
...
# Create a Lua function that will connect to the MySQL server,
# retrieve one row, and display the row.
# For explanations of the statement types used here, read the
# Lua tutorial in the Tarantool user manual.
<prompt>
localhost
>
</prompt><userinput>
SETOPT delimiter = '!'
</userinput>
<prompt>
localhost
>
</prompt><userinput>
lua function mysql_select ()
</userinput>
<prompt>
-
>
</prompt><userinput>
local resulter
</userinput>
<prompt>
-
>
</prompt><userinput>
local dbh = box.net.sql.connect(
</userinput>
<prompt>
-
>
</prompt><userinput>
'mysql', '127.0.0.1', 3306, 'root', '', 'test')
</userinput>
<prompt>
-
>
</prompt><userinput>
'mysql', '127.0.0.1', 3306, 'root', '
root
', 'test')
</userinput>
<prompt>
-
>
</prompt><userinput>
local test = dbh:select('SELECT * FROM test WHERE s1 = 1')
</userinput>
<prompt>
-
>
</prompt><userinput>
for i, card in pairs(test) do
</userinput>
<prompt>
-
>
</prompt><userinput>
print(
card.s2
)
</userinput>
<prompt>
-
>
</prompt><userinput>
resulter =
card.s2
</userinput>
<prompt>
-
>
</prompt><userinput>
end
</userinput>
<prompt>
-
>
</prompt><userinput>
return resulter
</userinput>
<prompt>
-
>
</prompt><userinput>
end!
</userinput>
---
...
...
...
@@ -164,8 +186,9 @@ plugins:
# Execute the Lua function.
<prompt>
localhost
>
</prompt><userinput>
CALL mysql_select()
</userinput>
2013-12-03 17:57:24.688 [12957] 102/iproto I
>
MySQL row
Call OK, 0 rows affected
localhost> CALL mysql_select()
Call OK, 1 rows affected
['MySQL row']
# Observe the result. It contains "MySQL row".
# So this is the row that was inserted into the MySQL database.
...
...
@@ -174,6 +197,7 @@ Call OK, 0 rows affected
<para
xml:id=
"plugin-postgresql-example"
>
<bridgehead
renderas=
"sect4"
>
PostgreSQL Example
</bridgehead>
Warning: This example is obsolete; a new example is being prepared to replace it.
This example assumes that a recent version of PostgreSQL has been installed.
The PostgreSQL library and include files are also necessary.
On Ubuntu they can be installed with
<programlisting><prompt>
$
</prompt><userinput>
sudo apt-get install libpq-dev
</userinput></programlisting>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment