Jump to content

from plain-text to mysql-db: how to store a triple / array?


Recommended Posts

hello dear php-experts,

 

well i want to do some data-saving in the next few days.  i have some data amount to store in a mysql-db.

well i am pretty sure this is a easy question for php-freaks

 


the question is: from plain-text to mysql-db: how to store a triple / array?

how to store this data into a mysql-db

have a dataset of 10 000 lines:

{'data_1': 'data_2', 'data_3': 'data_4', 'data_5': 'data_6', 'data_7': 'data_8'}
    
    
    
 how to store this dataset into the mysql db ?  
    

love to hear from you

greetings
 

hello dear guru

 

many thanks for the quick answer.

 

well each line is a new data-chunk or - in python language a triple.

 

 

eg like so:    data = { 'url':alk, 'name':name, 'cname':capname }
 

 

hope this may clear up a bit. - in case i need to provide more information - just let me know.

 

have a great  day

Create a table "whatever" (where whatever is a meaningful name for the data) and load the data into it. Once it is in a table you can manipulate further if required.

CREATE TABLE `whatever` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(255) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `cname` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
)

With the exception of the single quotes instead of double quotes, each line looks as though it is json encoded, so you could loop through each line, decode and insert into the table.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.