Re: MySQL



Dr. Deb wrote:

Does anyone know how to export a ".sql" file as a comma delinated file?

Thanks

Deb

..sql files are normally text scripts.

For example you might have this in a text file 'test.sql'

CREATE TABLE myTable
(
fields
};

Then you can use it from inside MySQL or on the commandline

mysql -u myname -p < test.sql


But for csv output of data, the principle is to
select into outfile
(you will see a couple of pages on this in the online mysql manual)

Example,
SELECT field1,field2,field3 INTO OUTFILE 'tmp.csv' FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM myTable;

You can of cause use the regular selection criteria.

From looking at that though you can see that other than for static exports,
it is crying out for a script wrapper to make it more flexible. So using
one of the programming or script languages in support is going to help a
great deal.

But as from MySQL 5, you have the option to use a csv engine. So you could
have the output of your query create a temporary table, which is in fact a
csv file.

So you can now select from your dbase files into a csv file. i.e. let the
engine do the work. I should imagine that keeping data in this form would
be resource hungry, but for intermediate files for clients it could prove
very useful. Particularly as you can have the engine do any re-sorts for
you, for large amounts of data the mysql engine is by far the better man
for the job than most clients.

.



Relevant Pages

  • Re: Totally ON topic!!!
    ... >>> MySQL isn't too difficult once you get the hang of it, ... >> as a .csv file, combine them all, and them run imports for each table ... I'm thinking a homebrewed script would ... ThePsyko ...
    (alt.2600)
  • Import from csv file to MySQL
    ... I'm in the middle of writing a script to import a csv file into mySQL ... (as apart of a bigger project) ...
    (comp.lang.php)
  • Re: MS Access to MySQL!!
    ... You can try exporting your data as a csv file and then use an import script ... I used the script here. ... > I'have a MS Access database and need to use it on a php site as a MySQL!! ...
    (alt.php)
  • Re: MS Access to MySQL!!
    ... > You can try exporting your data as a csv file and then use an import script ... > I used the script here. ... >>I'have a MS Access database and need to use it on a php site as a MySQL!! ... You could also look for MyAccess and MyODBC that will do it brilliantly. ...
    (alt.php)
  • Re: CSVDE Password Limitations - [WP]
    ... Your script was greata!!!! ... I am importing users into AD from CSV file and ran into password ... ' delimited by a quote followed by a comma. ...
    (microsoft.public.windows.server.active_directory)