Interacting with a Database from Scheme - mysql

i try to learn scheme and as a test project i wanted to create a very simple website with 1-2 database queries (MySQL preferred, but PostgreSQL would be ok, too).
I know it's not really schemes domain but i still want to see how far i can come.
Sadly, it seems i'm already stuck at using a database and googling for "scheme database" or any other combination including this words was (as expected considering the double meaning of scheme in this case) not very helpful.
Can you give me any hints on how to access a database from a scheme program?
I read something about scheme code interfacing a mysql client program to do that but i'd prefer something more direct.
Thanks.

GNU Guile already has a database interface that supports Postgres, MySQL and SQLite. It is
called Guile DBI. Other Scheme implementations you may try are: SISC (Can connect
to any JDBC compliant database, including MySQL) and Spark-Scheme (Can connect to any
ODBC compliant database, including MySQL and comes bundled with SQLite). Also note that most
Scheme implementations has some form of Foreign Function Interface that will help you
to write your own MySQL->Scheme Connector.

Related

How to migrate from Oracle 10g databse to MySql 8 database

We are currently using Oracle 10G database for the backend support of our application. We need to migrate the entire Oracle database schema into MySQL database, including all existing tables, views, procedures, triggers and sequences etc.
Can anyone kindly help me to guide the steps of migration, without hampering any schema definitions, keys and constraints etc.??
Also I came to know that MySQL does not support 'sequences'. In that case how can we convert the sequences which are present in Oracle database?
Please don't just mention any tool name, because I found few tools online but those are really lengthy and cumbersome processes to follow. Kindly mention step-wise, so that it's understandable easily.
I used Sql Developer IDE earlier, but it supports the reverse way migration, that is, from MySql to Oracle, not the one I need. Hence, I could not use it.
There is an Oracle Doc ID 1477151.1 for that case.
Though you asked to not mention any tool name, in that document Oracle advises to use MySQL Migration Wizard and provide some script examples for manual migration in case if automatisaton won't work.
Check those out. I hope that'll help
UPD: Again, I'm aware of you asking not to mention any tool, but here's another excerpt from that doc where even Oracle clearly says you have to use a third-party tool
Migration of Stored Procedures, Functions, Packages, Triggers, Views, Sequences must be performed using third party tools and needs manual effort. This document highlights method to perform data migration.
There are a host of third party tools, some of which are open source. For example:
http://www.sqlines.com/oracle-to-mysql
http://kettle.pentaho.com/
http://www.convert-in.com/ora2sql.htm
http://www.ispirer.com/products/oracle-to-mysql-migration

Is there any abstraction layer which makes a database look like Oracle?

We use Oracle in production, but in our company it's difficult to install in development environments.
Is there a way to let Perl (or any other language) send raw SQL statements via the DBI module (or the equivalent module for any other language to send SQL commands to a database) which are translated from Oracle SQL into MySQL or SQLite or something else?
So the application would think it was talking to Oracle but actually be talking to a different, easier to install, open source/free database.
It is impossible. Other database engines can't process Oracle queries. Simplest query in Oracle, for example, if you want to get name of a current user:
select user from dual
This query uses DUAL table, which is not present in any other DBMS. There is also a lot of Oracle-specific constructions (CONNECT BY, MINUS, etc.) which couldn't be processed in other engines.
The best way in your situation would be to create one Oracle installation in a virtual machine, and then copy it's image to another virtual machines for work.
The ANSI SQL is the abstraction layer you are referring to.
Assuming that all the tables exist in the target database and the RDBMS supports ANSI SQL then your query will transport to that other database flawlessly.
If you are looking to use something that is not defined in the standard, then it is unlikely to work correctly.
This is a link to the Oracle 11.2G position on the standard.
While talking about Oracle, their solution to the problem is to offer Oracle Database Gateways.

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.

Experience with direct data access components

I would like to know as to what has been the experience of using direct data access components like devart's MyDAC which allows a direct connection to the mysql server rather than through the client library or ODBC.
With AnyDAC you can acess almost all popular databases (MySQL, SQL Server, Oracle, Firebird, PostgreSQL, DB2, SQLite, ...). High-speed native direct access, many unique futures, unified API for access to cross-database features, excelent support.
I've never used MyDAC before. My experience is with DAC for MySQL from http://www.microolap.com/.
So far so good. Pretty easy to drop onto my Delphi projects, set the values of various properties, and then ready to connect. It has quite a number of useful components that allows you to retrieve data in several ways and you can use it easily with TDataSource.
No issues with deployment as well. All compiled nicely into one EXE.
Hope this helps!
Mydac is the best when you try to connect to MySql, it's fast stable and real powerful components.
Also the same for other components like Sdac and Odac.
and if you would like to use more than database you can use Unidac, which you can use to connect to (oracle, Sql server, Mysql, Interbase, Firebird and ODBC drivers.).
Another great point for Devart components that you don't need client library to be installed on the clients machine (libmysql.dll).

mysql dump outside the command line

Do any of the modern programming languages support mysqldump as a method, Or is it still the domain of command line environments.
If you're using PHP and don't mind using a GPL license, then phpMyAdmin contains some code for MySQL dump (as well as to other formats like CSV, etc).
Check out the file:
libraries/export/sql.php
There are APIs available (database drivers) for .NET, Delphi, and generic ODBC/DAO, as well as libraries for C/C++ and other languages. It's never going to be written directly into a mainstream language itself; that would restrict the language from being as general purpose and therefore make it less useful.
Delphi, for instance, has a database framework called DBExpress; there's a DBExpress driver included out of the box for MS SQL Server, Oracle, MySQL, DB2, and others; what drivers are available depend on the version (Professional, Enterprise, or Architect) you decide to buy. MySQL is available in all versions.
Using the DBExpress framework makes Delphi usable with any database engine that someone decides to provide a DBExpress driver for, and the drivers can be written in Delphi itself. That keeps Delphi more general purpose; it's not hard-coded to work with only a single RDBMS.
EDIT: As others have said (I think Jarret), the source to mysqldump is available. Using the wrappers available for your language of choice, you should be able to implement the same functionality based on that source.
Your instinct is right... it would be pretty tough for a programming language library to provide API access to mysqldump. The source to mysqldump is written in C, with its own main() function; it's designed to operate pretty much as its own program. It gets built as an executable, and much of the error reporting and output are handled using direct print statements to stdout, and not using return values that could be wrapped into a language-specific value.
When most bindings for a specific programming language are compiled (PHP, python, Delphi, .NET, etc), they link against libmysql, and libmysql contains no reference to the mysqldump program. I can't say for sure that no one has written a wrapper, but it would be a very bizarre wrapper indeed.
In other words, your best bet is to use a sub-process from your programming language of choice to call the mysqldump tool, and absorb the results either from stdin or from a temp file.
Your question is rather vague. Please describe what you want to accomplish, and what you have tried already.
That being said, if you want to produce a DB dump of a MySQL database in the way that mysqldump does, I know of no API that makes it possible directly. But there are numerous other ways of dumping / backing up a DB, and the mysqldump format has its share of problems (not well defined for one thing, hence not easy to parse). So you might consider an alternative approach.