def save_to_mysql(num_list): conn = MYSQLdb.connect(host='', user='', passwd='', port='') cur = conn.cursor() sql_create_database = 'create database if not EXISTS activecode_db' cur.execute(sql_create_database) conn.select_db('activecode_db') sql_create_table = 'create table if not exists active_codes(active_code CHAR(32) )' cur.execute(sql_create_table) cur.executemany('insert into actice_code VALUE(%s) ', num_list) conn.commit() cur.close() conn.close()
import MYSQLdb db = MYSQLdb.connect("localhost","root","lunatics@92","smartlab") cur = db.cursor() if cur != null: print('Sucessfull') else: print('!sucessfull')
import MYSQLdb db = MYSQLdb.connect("localhost", "testuser", "test123", "TESTDB") cursor = db.cursor() cursor.execute("SELECT VERSION()") data = cursor.fetchone() print "Database version: %s " % data db.close()
#!/usr/bin/env python import MYSQLdb con = MYSQLdb.connect('10.10.104.13', 3306, 'root', '@RSadmin123', 'htc-testbed') con.close()
def storeInDB(): con = MYSQLdb.connect("localhost","root","password","virtualDB")
def encryptThem(): con = MYSQLdb.connect("localhost","root","password","virtualDB")
#! /usr/lib/python import MYSQLdb import cgi db= MYSQLdb.connect(host ="localhost" , user="******", passwd="manpreet", dbname="MYdatabase") cur=db.cursor() cur.execute("SELECT VERSION()") vv=cur.fetchone() #for row in cur.fetchall(): # print row[0] #db.close()""" print "content-Type:text/html" print "database version is: %s" %vv db.close(); 1,1 Top