Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8995351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:36:30+00:00 2026-06-15T23:36:30+00:00

I am trying to make a python script that adds a video url and

  • 0

I am trying to make a python script that adds a video url and time to my videopost table in DB. This is my 3rd script at python. I am still learning. Also please tell me how to lower the execution time of this script.

Code:

  #!/usr/bin/python
  import MySQLdb
  import sys

  db = MySQLdb.connect (host = "host.com", user="myusername",passwd="pass", db = "dbname")

  cursor = db.cursor ()
  db.query("SELECT now()")
  result = db.use_result()
  time= str("%s" % \
      result.fetch_row()[0])
  print time
  db.close()
  cursor =db.cursor()
  vidurl = raw_input("Enter the URL to the video:")
  print vidurl

  cursor.execute ("""INSERT INTO videopost(vidurl, time) VALUES (%s, %s)""", (vidurl,time))
  db.commit()
  db.close()

The error i am getting in this is

  File "vidup.py", line 28, in <module>
  cursor.execute ("""INSERT INTO videopost(vidurl, time) VALUES (%s, %s)""", (vidurl,time))
  File "/usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-freebsd-8.2-RELEASE-amd64.egg/MySQLdb/cursors.py", line 155, in execute _mysql_exceptions.InterfaceError: (0, '')

Well thanks for the help. For people looking for solution i am posting the correction below:

  cursor.execute("SELECT now()")
  result = cursor.fetchall()
  time= str("%s" % \
        result[0])
  print time
  vidurl = raw_input("Enter the URL to the video:")
  print vidurl
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:36:31+00:00Added an answer on June 15, 2026 at 11:36 pm

    You are closing the connection and then trying to grab a cursor:

    db.close()
    cursor =db.cursor()
    

    Remove the first line and everything should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a small Python script that is executed by clicking an
I am trying to make a Python script that simply kicks me off of
I'm trying to make a python binding for the this library: http://code.google.com/p/hosterslib/ . I'm
I am trying to create a python script that opens a single page at
I'm trying to write a shell script that will make several targets into several
I'm trying to make a Python script run another program from its own path.
I have a python script that makes a series of url calls using urllib2.
I am trying to make a python script to find duplicate files in a
Basically, what I'm trying to do is simply make a small script that accesses
I'm trying to create a python script that will allow me to load up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.