Skip to content

Instantly share code, notes, and snippets.

@CHARITH1995
Created July 17, 2020 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CHARITH1995/eee9e2e8267515eadc9d6628bd97ddc2 to your computer and use it in GitHub Desktop.
Save CHARITH1995/eee9e2e8267515eadc9d6628bd97ddc2 to your computer and use it in GitHub Desktop.
save on mySQL database
sql = "INSERT INTO `newsarticles` (`source`, `sid`, `time`, `title`, `body`) VALUES (%s, %s, %s, %s, %s);" # those names depends on your database.
try:
cur.execute(sql, ('adaderana',0, date, title, contents))
db.commit()
except (MySQLdb.Error, MySQLdb.Warning) as e:
print ("SQL Error")
raise e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment