Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 how to insert list into database
#1
I am storing <p> tag data into list. When i apply insert query then last line of the list stored in the database.
I want to store all data in database that is available in link.
Below is the code of adding <p> tags data into list:

 content_html_container=soup_loop.find('div', class_="template__main")
    content=content_html_container.find_all('div',class_="story__content")

    for list_p in content:
        p=list_p.find_all('p')
        for li in p:
              p=li.text
#              print(p)
              p_list.append(p)
below is the database query:

 news_detail_query="INSERT INTO news_detail (`date`, heading, content, id_authors, id_categories) VALUES (%s, %s, %s, %s, %s)"
    insert_news=(timestamp,heading,p,authors_id,categories_id)
    result  = cursor.execute(news_detail_query, insert_news)
    cnx.commit()
Quote
#2
see: https://stackoverflow.com/questions/3070...base-table
Quote
#3
X = "HELLO"
Y = "RAJESH"
list = [X,Y]

INSERT INTO table VALUES ('%s') %s list
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Create application that will take information from database and insert into PDF sorrelsj 1 294 Aug-19-2019, 10:08 PM
Last Post: Gribouillis
  Store a python list of lists in a database to use for searches later on klllmmm 3 502 Jun-20-2019, 07:54 AM
Last Post: buran
  Creating a persistent list/database Trinx 1 303 Feb-27-2019, 06:20 PM
Last Post: ichabod801
  Insert list in particular column! Help! vndywarhol 0 559 Sep-17-2018, 11:14 PM
Last Post: vndywarhol
  insert list into sqlite3 mepyyeti 3 4,287 Jan-15-2018, 06:35 AM
Last Post: Gribouillis
  Newbie question for bulk insert into SQL Server database zydjohn 6 6,694 Dec-14-2017, 11:04 PM
Last Post: Larz60+
  Python 3 MySQL database insert error georgian2all 7 3,059 Aug-01-2017, 06:37 PM
Last Post: Larz60+
  Insert using psycopg giving syntax error near "INSERT INTO" olgethorpe 4 5,333 Jul-21-2017, 07:39 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)