Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-30-2006, 12:51 AM   #1
alex79
Confirmed User
 
Join Date: Jun 2002
Location: france
Posts: 996
mysql import from text file

i have some text files that i want to import in mysql..
fields are delimitated by "|"
first row contain the columns name
is there any possibility to import them directelly to mysql without creating the tables first? tables must be autocreated from first line in the moment of the import..
i know there is mysqlimport utility but require that tabels to be already created before the import..
__________________
alex79 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-30-2006, 01:15 AM   #2
Solid Bob
Confirmed User
 
Join Date: Apr 2006
Location: Easy Webcam Pro
Posts: 1,213
Why would you possibly need it to autocreate from the first line going in?
__________________
[email protected]
Solid Bob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-30-2006, 03:33 AM   #3
FlowerKid
Confirmed User
 
Join Date: Sep 2005
Location: Zurich
Posts: 1,045
I think you need a little script (PHP, Perl, ...) that reads the text file and creates the SQL commands for adding the tables and insert the content.
__________________
FlowerKid is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-03-2006, 12:21 AM   #4
teksonline
So Fucking Banned
 
Join Date: Jan 2005
Location: At My Desk
Posts: 2,904
Creating the tables can be done with various command line tricks or simple scripts, but the fact is, what is data, if it is not scoped correctly.. ints, text, vars, etc and placed in properly named fields, or in you're explanation "columns"
teksonline is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-03-2006, 12:22 AM   #5
squishypimp
PostMaster General
 
Join Date: Aug 2006
Posts: 10,781
bump for info
__________________
squishypimp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-03-2006, 12:23 AM   #6
Solid Bob
Confirmed User
 
Join Date: Apr 2006
Location: Easy Webcam Pro
Posts: 1,213
Quote:
Originally Posted by squishypimp
bump for info
Page 10 already?
__________________
[email protected]
Solid Bob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-03-2006, 05:31 AM   #7
psili
Confirmed User
 
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
Look up "load data infile".... off the top of my head, and not checking syntax, it would look something like:

mysql>load data in file 'data.txt' into table [table_name] fields terminated by '|' lines terminated by '\n' ignore 1 lines
__________________
Your post count means nothing.
psili is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-03-2006, 05:38 AM   #8
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Quote:
Originally Posted by psili
Look up "load data infile".... off the top of my head, and not checking syntax, it would look something like:

mysql>load data in file 'data.txt' into table [table_name] fields terminated by '|' lines terminated by '\n' ignore 1 lines

good thing you've read the thread first
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-03-2006, 05:42 AM   #9
psili
Confirmed User
 
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
Quote:
Originally Posted by darksoul
good thing you've read the thread first
I'm a bad person.

Forgot the table create statement.
__________________
Your post count means nothing.
psili is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.