Erlang Central

Difference between pages "MySQL native client" and "User:EudoraArriaga266"

(Difference between pages)

m
 
(Created page with "There are several video games available today which it can sometimes be hard to tell the ones that [http://www.happywheelz.com/ happy wheels ] worth playing and which ones tha...")
 
Line 1: Line 1:
==Author==
+
There are several video games available today which it can sometimes be hard to tell the ones that [http://www.happywheelz.com/ happy wheels ] worth playing and which ones that are totally waste. There are various techniques you could play childish games now, for example with a Ps3 or Xbox 360 console. Still there's no need to pay for many dollars anymore since there are literally thousands of fantastic flash games which can be on the net. One good reason why people don't make an effort playing online display games is caused by it may be difficult to get the great versions, [http://www.happywheelz.com/ happy wheels ] we're going to refer to among the best display games and that means you know what games to try out the next time you're bored stiff at college, work as well as whatever!
[[User:Krasnopolski]]
+
  
==Introduction==
+
Series Rider: The name of the game provide you with a huge clue as to what that game is around, use a reckon. Yes, may game where you have in order to ride a range trying to build a design that will allow your own [http://www.happywheelz.com/ happy wheels ] to finish an entire course you have just designed. It's sort of difficult to explain exactly why the game is very very good, but the truth is should preferably play that for yourself.
[http://sourceforge.net/projects/erlmysql Erlang client] for MySQl server
+
is a native client. It means the client is directly connecting to the server and using
+
low level (network socket level) connection protocol. So advantage of the client as a native
+
is speed and performance. Disadvantage is that client design tightly coupled with MySQL
+
connection protocol, but MySQL team is conservative enough with it.
+
  
==Design==
+
Excellent Mario Entire world: Will i even should give this particular flash game an introduction? I [http://www.happywheelz.com/ happy wheels ] think therefore , Mario video game titles are just very fun and excellent time wasters. I've all [http://www.happywheelz.com/ happy wheels ] hours and hours performing Super Mario game titles, take a look at perform it online? Body fat ought to spent cash on Nintendo's creative designers Ds games or whatever ever again, while you can participate in your favourite Mario games immediately from your laptop or computer!
The MySQL client is implemented as Erlang/OTP application. Root supervisor of the client
+
manages a set of datasource processes each of them can be pointed to different MySQl servers
+
or to the same but differently configured. To create a datasource process (or object)
+
we can use function from the client API:
+
<code>
+
my:new_datasource(my_ds, #datasource{
+
host = "localhost",
+
port = 3306,
+
database = "",
+
user = "root",
+
password = "root"}
+
).
+
</code>
+
Datasource is supervisor in own turn and keeps management under one connection pool process
+
and a few active connection processes to server. The connection pool stores a reusable
+
ip/tcp socket and is tracking their life cycles. When new connection process is creating then the
+
connection pool is trying to provide an existed but idle socket. If set of idle socket is empty
+
connection pool creates new one. If connection process has closed then assigned socket becomes idle
+
and goes to set of idle sockets of the pool.
+
  
==Supported features==
+
The Helicopter Online game: This online game is so simple, yet really incredibly addicting. [http://www.happywheelz.com/ happy wheels ] activity is to find the highest rating, which you may comes from surviving over the course that is certainly packed with green obstructs (that'll kill a person if you battle straight into them). Anyone click the computer mouse to go greater and don't whatever it takes to leave the bird drop a bit. This specific game is an excellent video game if you would like possess a little level of competition with your friends to see having the best with game playing.
The client supports the following client features of MySQL server:
+
* configure client connection using #client_options{} record
+
* compression mode for transfer data through connection
+
* transfer of very long packets as a multi sub-packets
+
* prepared statements execution
+
* transfer a long statement parameters (blob parameters)
+
* fetch cursor on server previously generated by prepared statement
+
* transaction execution
+
 
+
==Getting started==
+
We have already created datasource object above. So now we can obtain connection to our server:
+
<code>
+
Conn = my:get_connection(my_ds)
+
</code>
+
Let's create new database (or schema) on the server:
+
<code>
+
my:execute_query(Conn, "CREATE DATABASE IF NOT EXISTS testDB")
+
</code>
+
Next step is a table creation:
+
<code>
+
my:execute_query(Conn,
+
"CREATE TABLE testDB.sample_table ("
+
"id bigint(20) NOT NULL AUTO_INCREMENT,"
+
"name varchar(45) DEFAULT NULL,"
+
"PRIMARY KEY (id)"
+
") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8"
+
)
+
</code>
+
It is time to insert something to new table:
+
<code>
+
my:execute_query(Conn,  
+
"INSERT INTO testDB.sample_table(name) "
+
"VALUES ('Alex'), ('John')"
+
)
+
</code>
+
And finally we can extract this rows from the table:
+
<code>
+
{Metadata, Rows} = my:execute_query(Conn, "SELECT * FROM testDB.sample_table"),
+
io:format("Result: ~p~n", [Rows])
+
</code>
+
We can see on console something like this:
+
<code>
+
Result: [{rs_row_data, [1,"Alex"]},{rs_row_data, [2,"John"]}]
+
</code>
+
Query returns a tuple that contains two members. First one is metadata record
+
represented information about table fields and second one is list of records represented
+
rows of query result. Each row contains values of fields of SELECT statement. In our case
+
there are 'id' and 'name' fields.
+
 
+
==Prepared statement==
+
Let's prepare a very simple statement:
+
<code>
+
Handle = my:get_prepared_statement_handle(Conn, "SELECT name FROM testDB.sample_table WHERE id = ?")
+
</code>
+
Now execute it:
+
<code>
+
{Metadata, Rows} = my:execute_statement(Conn, Handle, [?MYSQL_TYPE_LONGLONG], [1]),
+
io:format("Result: ~p~n", [Rows])
+
</code>
+
Result has to be:
+
<code>
+
Result: [{rs_row_data, [1,"Alex"]}]
+
</code>
+
 
+
18:56, 26 September 2011 (BST)<br>
+
[[Category:HowTo]]
+
[[Category:Interfacing_Erlang]]
+

Latest revision as of 06:47, 7 November 2012

There are several video games available today which it can sometimes be hard to tell the ones that happy wheels worth playing and which ones that are totally waste. There are various techniques you could play childish games now, for example with a Ps3 or Xbox 360 console. Still there's no need to pay for many dollars anymore since there are literally thousands of fantastic flash games which can be on the net. One good reason why people don't make an effort playing online display games is caused by it may be difficult to get the great versions, happy wheels we're going to refer to among the best display games and that means you know what games to try out the next time you're bored stiff at college, work as well as whatever!

Series Rider: The name of the game provide you with a huge clue as to what that game is around, use a reckon. Yes, may game where you have in order to ride a range trying to build a design that will allow your own happy wheels to finish an entire course you have just designed. It's sort of difficult to explain exactly why the game is very very good, but the truth is should preferably play that for yourself.

Excellent Mario Entire world: Will i even should give this particular flash game an introduction? I happy wheels think therefore , Mario video game titles are just very fun and excellent time wasters. I've all happy wheels hours and hours performing Super Mario game titles, take a look at perform it online? Body fat ought to spent cash on Nintendo's creative designers Ds games or whatever ever again, while you can participate in your favourite Mario games immediately from your laptop or computer!

The Helicopter Online game: This online game is so simple, yet really incredibly addicting. happy wheels activity is to find the highest rating, which you may comes from surviving over the course that is certainly packed with green obstructs (that'll kill a person if you battle straight into them). Anyone click the computer mouse to go greater and don't whatever it takes to leave the bird drop a bit. This specific game is an excellent video game if you would like possess a little level of competition with your friends to see having the best with game playing.