PL/Ruby equivalent in MySQL - mysql

PL/Ruby is a loadable procedural language for Postgres that lets you use Ruby to write user defined functions for the database.
Anyone know of an equivalent way of writing user defined functions for MySQL in Ruby?

Starting from version 5 (I think) Mysql supports stored procedures, but the syntax is restricted to SQL:2003 which is somewhat similar to PL/SQL.
Other languages aren't supported and I'm not aware of any projects offering ruby support. Last time I checked the PL/Ruby extensions to postgres were still a bit wonky as well, though.

Mysql as far as I am aware only supports MySQLs own stored procedure language.
I'm a postgresql fan too, and this is something that has always frustrated me about MySQL when I have had no choice but to use it. :(

Related

MySQL Syntax for SQLite Syntax

I've started using SQLite for my Android applications. What I would like to know is where I can find a list of queries to use, are they the same for MySQL, and would I be able to use similar queries from MySQL?
SQLite provides a pretty good implementation of the SQL standard. Check out the syntax here. There is a prominent link in the first paragraph that describes omissions.
EDIT: No stored procedures or functions. You can mimic these in your code at runtime, however, using prepared statements
List of queries? You would need to use 'SQLiteDatabase.query' set of methods to query your SQLite database in your Android app. There would be SQLite specific SQL that you would need to consider while migrating your MySQL queries.

General Questions about MySQL and MySQLite

I am going to be writing to a MySQLite database file, using Perl's DBD:SQLite module, and I wondering if it is possible for this file to be read by any distribution of MySQL? Is there a better way to create a simple MySQL database (using Perl)?
If it means anything, I'm only going to be using the database to store key-value pairs based on unique ID numbers for the keys. I tried BerkeleyDB but there is little support for it on Perl and I could not get it to work correctly in the past on certain versions of Windows.
Edit: I am aware that BerkeleyDB is a better way to do this, but when I was writing scripts for it, most of the methods have TODO, and I've had mysterious bugs on Windows Server 2003 using the same airtight code that ran for 2 weeks straight on my Win7 machine at home.
MySQL and SQLite are completely separate RDBMS systems. There is no such thing as MySQLite. To the best of my knowledge, MySQL cannot read SQLite databases.
If all you really want is a key-value store, perhaps look at Redis: http://code.google.com/p/redis/
I use Perl's DBI module which I can use to read databases using either MySQL or SQLite. All you need is the correct driver. In fact, if you write your program correctly, the backend database (either SQLite or MySql) is irrelevant. Your program will work with either one.
However, you can't use a SQLite database and then treat it as a MySQL database. They're two different creatures. Your program can be database agnostic, but once you chose a database, you can't switch back and forth. It'd be like opening an Oracle database as a MySQL database.
See This posting on Perl Monks for more info.
BerkeleyDB is well supported by perl. You have a choice between the older DB_File and the more fully featured BerkeleyDB module.
But there are tons of choices. If you don't want to have to run a separate server process, use DBI and DBD::SQLite or BerkeleyDB or any of the AnyDBM_File modules. For a simple server-based key-value store, there's redis or the older memcached.

How reliable are mySQL stored procedures?

This not a go/no go question. I've used all kinds of 4GLs (PL/SQL, T-SQL, PGSQL etc.) for database back-end coding and find very useful to establish data layer "closest" to database engine.
Now MySQL stored procedures got my attention and very interested in coding in this brand new 4GL platform.
I would like to start using it in one of my proof of concept projects. What you folks think about MySQL stored procedures? Crucial question is; Is it reliable? How "Oracle Corporation" supports MySQL stored procedures (i.e. documentation, forums etc.)?
Thanks
Support started in v5.0, it's currently in v5.1 (v5.5 is in the pipe). If they weren't reliable, they'd have been removed.
I don't know what you mean by "how Oracle supports it" - the syntax is different, rarely (if ever) will you be able to port an Oracle stored procedure directly to MySQL without alteration.
A mySQL stored procedure will be as reliable as you make it. If you write it to do everything you need then it will be fine. If you don't it wont.
As #OMG states they began supporting in version 5.0.
What do you mean when you ask how Oracle supports it?

Possible to write MySQL stored procedures in ruby?

I have heard that one in PostgreSQL could write stored procedures in ruby (also python/java/c++).
Is this possible in MySQL?
Because I dont want to learn their own language for it.
Thanks
No, you can't. Just install PostgreSQL on your (virtual) system and install PL/Ruby as well:
http://moulon.inra.fr/ruby/plruby.html
Setting up a virtual machine (in VMware or Virtual Box) using Ubuntu with PostgreSQL, takes just a few minutes:
https://help.ubuntu.com/10.04/serverguide/C/postgresql.html
Simply put - nope. In MySQL you have to write a SP in their language or a UDF in C/C++. I brought up a C/C++ UDF, but I don't believe you can even really do a stored procedure in them.
They don't support different languages via a pluggable system like PostgreSQL.

Need a tool to convert postgres database to mysql

I found the mysql migration toolkit which will migrate the tables.But is there something which will convert the functions as well.
Almost certainly not.
If your functions are in the SQL language only, it should probably be doable. But any of the many other languages supported by PostgreSQL (pl/pgsql, perl, python etc) are completely different, and contain much functionality that's simply not supported on MySQL.
most likely not. the stored procedure and function language differs greatly between postgresql and mysql. such an application would be costly to develop.
There are several data migration tools available on Google to convert database. I use dbload for example.