General Questions about MySQL and MySQLite - mysql

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.

Related

MYSQL Database offline use

Is there a way to use a MYSQL database without the database management system.. Like use tables offline without installing the db management system on the machine..
If there is can you please point me in the right direction?
Thank you!
As far as I know, there is no way to do this.
However, there is a portable DBMS SQLIte. It comes in different ways and can be used on other platform with different programming languages.
After reading your comment, I'm almost sure, this is what you need.
It's not that fast as MySQL I guess, but it works.
You can use The embedded MySQL Server Library to access MySQL data files without running the MySQL server.
You can setup a database to work on your localhost. This will be offline unless you setup the front-end stuff to let the internet interact with it.
What exactly do you mean "without the database management system"? You always need a way of interacting with it, even if it is offline. (Otherwise how can it work for you?)
The server side piece of the application, mysql-server, is needed at a minumum to run mysql. This server application comes with all the tools built-in to manage the instance. I doubt you can prevent installation of this.
If you've actually opened the table files in a hex or text editor, you'll see that you will definitely need the mysql application installed to make any sense of them to use them. Sure the records are all there in plain text (.myd files for myisam, the ibdata1 file for innodb tables), but it would be a complete time-waster devising a custom app to parse or update the file structure, as well as trying to tie in table structure contained in the related files for each table.

MySQL database manipulation program for Windows? Like MS Access or MS SQL?

Is there any program (preferably official) for Windows that can be used to manipulate MySQL data dumps?
For example, easily importing a MySQL text dump and create the database for all kinds of manipulations (you know, common data operations such as select, update, insert, delete, export into CSV, etc.) via a GUI interface. Much like what you can do with MS Excel and MS Access.
I know only phpMyAdmin which requires a local web server environment which might a little too much for what I need.
I thought http://dev.mysql.com/downloads/mysql/ was what I needed and installed to find out that it's not.
Any such tools exist? I ask this is actually because these MySQL dumps are for my users who know nothing about SQL or anything technical. This is for them, not me. After they downloaded the SQL I provided, they ask me: "How can I open it?"
I tried to provide them CSV, but CSV generated by this approach: http://www.kavoir.com/2010/11/mysql-export-table-to-csv-text-files-for-excel.html would contain stuff like \" if the original data contains ". When you open the CSV in Excel, \" are all over the place.
http://www.webyog.com/en/
I used to use SQLyog at my last job. It's a pretty decent GUI tool for interacting with MySQL, either local or remote. It'll cost you $99 at the cheapest, but you can try it for 30 days. If you like it and it makes life easier, it could be worth the $99, as well.
Running a local server is actually pretty easy. I use xampp which was really easy to install and came set up and ready to use phpMyAdmin. It's also really easy to shut the whole server (or just parts of it) down when it's not in use to conserve system resources.

Interacting with a Database from Scheme

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.

MySQL "filegroup"?

Coming for using Sql Server where there are file-groups, i was wondering if there is (i'm sure there is) something similar in MySQL. After all the database cant be limited to just one hard drive( if using windows that is). I've tried to search but its hard to find the something that you don't know the name of!.
By default a MySQL Server instance stores all data files under a single data directory.
There are ways to use symbolic links to spread files over multiple drives if you're clever.
Or you can use Partitioning to store your database over multiple directories. But I personally think the implementation of Partitioning prior to MySQL 5.5 is too awkward to be useful.
Re your comment about using a SAN: Here's an article: When would you use a SAN with MySQL?

How to import data to an in-memory database?

Are there any ways to import data in databases such as MS SQL, MySQL into in-memory databases like HSQLDB, H2 etc ?
H2 supports a special database URL that initialized the database from a SQL script file:
"jdbc:h2:mem;INIT=RUNSCRIPT FROM '~/create.sql'"
HSQLDB and Apache Derby don't support such a feature as far as I know.
I think you need to do
query the data out from MS SQL
import the data into in-memory DB with its API
Either SQL expressions or DB related APIs
In Hibernate: Adding import.sql to the class path works great, hbm2dll checks if the file exists and executes it. The only details is that every sql command most be on one row, otherwise it will fail to execute
You could dump the data as SQL INSERT statements then read it back.
You could read to a temporay object (like a struct) then write back to the internal db.
Look at the free "universal database converter" http://eva-3-universal-database-converter-udc.optadat-com.qarchive.org/ -- it does claim to support MySQL, MS-SQL, and HSQLDB, among others.
It really depends on what ways you think about.
Is there a tool that could do it automatically without programming? Maybe.
Do you want to develop it? Then find out whether your favorite language supports both database engines(standard and in memory) and if it does, just write a script that does it.
Process everything in chunks(fetch n rows at a time then insert them; repeat). How big the chunk size? It's up to you, try different sizes(say 100, 500, 1k etc.) see which one performs better on your hardware, fine tune to the sweet spot.
If your favorite language on the other hand doesn't support both of them, try using something that does.
You can use dbunit for dumping the database to xml files and importing it back to another rdbms.
Latest versions of HSQLDB allow you to open a CSV (comma separated values) or other delimiter separated data file as a TEXT TABLE in HSQLDB even with mem: databases, which can then be copied to other tables.
As others have pointed out, there are also capable and well maintained third party tools for this purpose.