import MySQLdb
db = MySQLdb.connect(host="localhost", user="john", passwd="megajonhy", db="jonhydb")
cursor = db.cursor()
for i in range(0,500):
cursor.execute("INSERT INTO MyTable VALUES('Some string', 1337);")
import postgresql
db = postgresql.open("pq://postgres:SupaPass@127.0.0.1/testdb")
prepstatement = db.prepare("INSERT INTO MyTable VALUES($1, $2, $3);")
with db.xact():
for i in range(0, 500):
prepstatement('Some string', 1337, ["a", "list"])
import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=user;PWD=pass')
cursor = cnxn.cursor()
for i in range(0, 500):
cursor.execute("INSERT INTO MyTable VALUES('Some string', 1337);")
Note that this is a library that will do a lot of magic for you, hence you'd might not learn as much from it or desire all it's functionality.
from sqlalchemy import create_engine
db = create_engine("mssql://me:pass@localhost/testdb")
for i in range(0, 500):
db.execute("INSERT INTO MyTable VALUES('Some string', 1337);"):
How get get POST/GET data
And finally, we have no clue as to how you run the script.
But you mentioned web development and well, assuming you run the script as CGI, here's how to get the POST/GET data:
import cgi
form = cgi.FieldStorage()
print form["username"]
Let me Google this for you