Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import MySQLdb
- import getpass
- connection=MySQLdb.connect("localhost","amstan",getpass.getpass("enter the db password: "),"contest")
- cursor=connection.cursor()
- def query(*args):
- print args
- cursor.execute(*args)
- while True:
- orgname=raw_input("New organization name: ")
- if orgname=="":
- break
- query("""insert into organizations (name) VALUES (%s);""",(orgname,))
- query("""select * from organizations where name = %s;""",(orgname,))
- orgid=int(cursor.fetchone()[0])
- print "org_id = %s" % (orgid,)
- while True:
- username=raw_input("Username to be added to the group: ")
- if username=="":
- break
- query("update users SET org_id = %s WHERE username = %s;",(orgid,username))
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement