LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-09-2009, 04:28 AM   #1
jwnjoroge
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
Question inserting the content of a python list to a mysql database


I am new to working in linux though have abit of exposure in working on a mysql database. Am working on a project and some part of the script is able to read for me a python list which i use in the main program to give me
seq = [10,12,13,14,15,16,17,18]

am trying to use use a for loop to write back the content of the list to a colunm in the database

for x in seq:
sql_stm = 'insert into testinsert (time_after) values (%d)', (x)
cursor.execute(sql_stm)

but keep getting an error. Can someone help me on how i can write the content of the list to the column time-after
 
Old 09-09-2009, 06:51 AM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Is x a Tuple now, and not an element of the list?

What's the error?
Suggest putting code samples in code blocks, because your example's indentation is wrong. You'd be getting an error from that alone.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
store list items written in cgi script to mysql database gsr_kashyap Programming 5 01-28-2009 01:08 AM
Mailing list in a MySQL database Hjalte Linux - Server 2 09-02-2008 02:41 AM
OOffice: Inserting PDF, as link with real page content, and references , how ?? frenchn00b Linux - General 0 11-21-2007 04:26 PM
Problem Inserting Data In A Mysql Database Using PHP Dapernia Programming 5 09-17-2007 10:05 AM
Inserting element to a list of list in C suwandy_chandra Programming 2 03-09-2004 03:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration