class class_model(object): MySQLConnection = mysql.builder() sqlhub.processConnection = MySQLConnection(user = buu_config.config.mysql_username, password = buu_config.config.mysql_password, host = buu_config.config.mysql_addr, db = buu_config.config.mysql_database) class User(SQLObject): userName = StringCol() class Printer(SQLObject): printer_type = TinyIntCol() printer_value = StringCol() printer_name = StringCol() user = ForeignKey('User') class PrintJob(SQLObject): page_num = IntCol() file_name = StringCol() user = ForeignKey('User') printer = ForeignKey('Printer') timestamp = TimestampCol() def init(): if not sqlhub.processConnection.tableExists('user'): class_model.User.createTable() if not sqlhub.processConnection.tableExists('printer'): class_model.Printer.createTable() if not sqlhub.processConnection.tableExists('print_job'): class_model.PrintJob.createTable()
class class_model(object): MySQLConnection = mysql.builder() sqlhub.processConnection = MySQLConnection( user=buu_config.config.mysql_username, password=buu_config.config.mysql_password, host=buu_config.config.mysql_addr, db=buu_config.config.mysql_database) class User(SQLObject): userName = StringCol() class Card(SQLObject): user_name = StringCol() password = StringCol() user = ForeignKey('User') class Switch(SQLObject): function_name = StringCol() function_enable = TinyIntCol() function_option = StringCol() user = ForeignKey('User') def init(): if not sqlhub.processConnection.tableExists('user'): class_model.User.createTable() if not sqlhub.processConnection.tableExists('card'): class_model.Card.createTable() if not sqlhub.processConnection.tableExists('switch'): class_model.Switch.createTable()
tableName_Content_Search =projectSpecs.tableName_Content_Search tableName_Content_Score = projectSpecs.tableName_Content_Score tableName_Search = projectSpecs.tableName_Search tableName_Metasearch_Search = projectSpecs.tableName_Metasearch_Search tableName_Url_Html = projectSpecs.tableName_Url_Html tableName_Search_Viewcriteria = projectSpecs.tableName_Search_Viewcriteria tableName_Negationwords = projectSpecs.tableName_Negationwords tableName_BadUrlFragment = projectSpecs.tableName_BadUrlFragment tableName_Poswords = projectSpecs.tableName_Poswords tableName_Negwords = projectSpecs.tableName_Negwords tableName_Obscenewords = projectSpecs.tableName_Obscenewords tableName_Scoremethods = projectSpecs.tableName_Scoremethods tableName_Scores = projectSpecs.tableName_Scores tableName_Wordcount = projectSpecs.tableName_Wordcount conn = mysql.builder()(user=dbUser, password=dbPass, host=dbHost, db=dbSchema, use_unicode = True) ###Database Objects### class Url(SQLObject): #An object to represent the table 'Urls' _connection = conn #set the connection object class sqlmeta: fromDatabase = True #uses db table names and characteristics table = tableName_Url #this allows the table to be called something besides the class name class UrlSearch(SQLObject): #Representes relates search id, order, depth to the url _connection = conn class sqlmeta: fromDatabase = True table = tableName_Url_Search
from sqlobject.mysql import builder from the_crawler.settings import DB_HOST, DB_NAME, DB_PASS, DB_USER conn = builder()(user=DB_USER, password=DB_PASS, host=DB_HOST, db=DB_NAME)
import os import logging from flask import Flask, jsonify, request import sqlobject from sqlobject.mysql import builder conn = builder()(user='******', password='******', host='localhost', db='sqlobject') app = Flask(__name__) class Student(sqlobject.SQLObject): _connection = conn name = sqlobject.StringCol(length=255) backlog = sqlobject.IntCol(name=None) subjects = sqlobject.MultipleJoin('Subjects') stu = Student.createTable(ifNotExists=True) class Subjects(sqlobject.SQLObject): _connection = conn maths = sqlobject.IntCol(name=None) hindi = sqlobject.IntCol(name=None) science = sqlobject.IntCol(name=None) english = sqlobject.IntCol(name=None)
import sqlobject from sqlobject.mysql import builder conn=builder()(user='******',password='******',host='localhost',db='sqlobject_demo')
tableName_Content = projectSpecs.tableName_Content tableName_Content_Search =projectSpecs.tableName_Content_Search tableName_Content_Score = projectSpecs.tableName_Content_Score tableName_Search = projectSpecs.tableName_Search tableName_Metasearch_Search = projectSpecs.tableName_Metasearch_Search tableName_Url_Html = projectSpecs.tableName_Url_Html tableName_Search_Viewcriteria = projectSpecs.tableName_Search_Viewcriteria tableName_BadUrlFragment=projectSpecs.tableName_Negationwords tableName_BadUrlFragment=projectSpecs.tableName_Poswords tableName_BadUrlFragment=projectSpecs.tableName_Negwords tableName_BadUrlFragment=projectSpecs.tableName_Obscenewords tableName_BadUrlFragment=projectSpecs.tableName_Scoremethods tableName_BadUrlFragment=projectSpecs.tableName_Scores tableName_BadUrlFragment=projectSpecs.tableName_Wordcount conn = mysql.builder()(user=dbUser, password=dbPass, host=dbHost, db=dbSchema, use_unicode = True, sqlobject_encoding = 'utf8') a=1 ###Database Objects### class Url(SQLObject): #An object to represent the table 'Urls' _connection = conn #set the connection object class sqlmeta: fromDatabase = True #uses db table names and characteristics table = tableName_Url #this allows the table to be called something besides the class name class UrlSearch(SQLObject): #Representes relates search id, order, depth to the url _connection = conn class sqlmeta: fromDatabase = True
import sqlobject from sqlobject.mysql import builder conn = builder()(user='******', passwd='segredo', host='localhost', db='pedrinho')
__author__ = 'Lewis' # We need a schema... :( from sqlobject import * from sqlobject.mysql import builder conn = builder()(user='******', password='******', host='localhost', db='fed_uni_mac_cloud') #class PhoneNumber(SQLObject): # _connection = conn # number = StringCol(length=14, unique=True) # owner = StringCol(length=255) # lastCall = DateTimeCol(default=None) #PhoneNumber.createTable(ifNotExists=True) #PhoneNumber.dropTable(ifExists=True) #call = PhoneNumber.select(PhoneNumber.q.number=='(415) 555-1212') #print call #print call[0].owner
import sqlobject from sqlobject.mysql import builder conn = builder()(user='******', password='******', host='localhost', db='test', charset="utf8") # class py_user(sqlobject.SQLObject): # _connection = conn # user = sqlobject.StringCol(length=14, unique=True) # password = sqlobject.StringCol(length=255) # create_time = sqlobject.StringCol(length=255) # login_time = sqlobject.StringCol(length=255) # # print("创建py_user成功") # # # class py_key(sqlobject.SQLObject): # _connection = conn # public_pen = sqlobject.StringCol(length=500) # private_pen = sqlobject.StringCol(length=500) # create_time = sqlobject.StringCol(length=500) # update_time = sqlobject.StringCol(length=500) # ip = sqlobject.StringCol(length=500) # # print("创建py_key成功") # # # class py_rule(sqlobject.SQLObject): # _connection = conn # title = sqlobject.StringCol(length=500)
class class_model(object): MySQLConnection = mysql.builder() sqlhub.processConnection = MySQLConnection(user = buu_config.config.mysql_username, password = buu_config.config.mysql_password, host = buu_config.config.mysql_addr, db = buu_config.config.mysql_database) class User(SQLObject): userName = StringCol() class Card(SQLObject): user_name = StringCol() password = StringCol() user = ForeignKey('User') class Switch(SQLObject): function_name = StringCol() function_enable = TinyIntCol() function_option = StringCol() user = ForeignKey('User') class Printer(SQLObject): printer_type = TinyIntCol() printer_value = StringCol() printer_name = StringCol() user = ForeignKey('User') class PrintJob(SQLObject): page_num = IntCol() file_name = StringCol() user = ForeignKey('User') printer = ForeignKey('Printer') class Lib(SQLObject): user_name = StringCol() password = StringCol() user = ForeignKey('User') class Jwxt(SQLObject): user_name = StringCol() password = StringCol() user = ForeignKey('User') def init(): if not sqlhub.processConnection.tableExists('user'): class_model.User.createTable() if not sqlhub.processConnection.tableExists('card'): class_model.Card.createTable() if not sqlhub.processConnection.tableExists('switch'): class_model.Switch.createTable() if not sqlhub.processConnection.tableExists('printer'): class_model.Printer.createTable() if not sqlhub.processConnection.tableExists('print_job'): class_model.PrintJob.createTable() if not sqlhub.processConnection.tableExists('lib'): class_model.Lib.createTable() if not sqlhub.processConnection.tableExists('jwxt'): class_model.Jwxt.createTable()
#!coding:utf-8 from sqlobject import connectionForURI, sqlhub from sqlobject.mysql import builder from tornado.options import options # 初始化一个数据的连接,用来在models中传递连接,加上编码,要不可能会报未知的错误 conn = builder()(user='******', password='******', host='localhost', db='kaoyan', charset='utf8')