GithubHelp home page GithubHelp logo

entitysimulator's Introduction

EntitySimulator

一个模拟Entity对Entity数据库表进行操作的工具。

部分代码和设计理论来自django,任何与django相关的内容请参考以下内容: https://docs.djangoproject.com/en/1.11/ref/models/querysets/#queryset-api https://docs.djangoproject.com/en/1.11/topics/db/queries/#complex-lookups-with-q https://docs.djangoproject.com/en/1.11/ref/models/expressions/#django.db.models.F

安装方法:

1.更新common目录下所有内容并复制到KBEngine引擎的“kbe\res\scripts\common\”下面(当然,复制到自身脚本层上面也可以)。
2.由于MysqlUtility.py用到了Mysql-Connector的一些方法,因此需要到https://cdn.mysql.com//Downloads/Connector-Python/mysql-connector-python-2.1.6.zip处下载python版本的mysql-connector。
3.解压缩mysql-connector-python-2.1.6.zip并复制“mysql-connector-python-2.1.6\lib\mysql”目录到KBEngine引擎的“kbe\res\scripts\common\”下面。
4.over.

测试代码:

from EntitySimulator.EntityModel import EntityModel
from EntitySimulator import Fields

class TestTable( EntityModel ):
	class Meta:
		db_table = "custom_TestTable"

	databaseID = Fields.INT32( db_column = "id", primary_key = True )
	i1         = Fields.INT32( db_column = "sm_i1" )
	i2         = Fields.FLOAT( db_column = "sm_i2" )
	sm_s1      = Fields.UNICODE(default = "test1")
	sm_s2      = Fields.BLOB(default = b'gdsadf')

telnet localhost 40000

g_result = []
def cb(success, models): g_result.append((success, models))

TestTable.objects.select(cb)
g_result[-1][-1]

TestTable(i1 = 12, i2 = 34.0, sm_s1 = "abc", sm_s2 = b"gggtttvvv")
m = TestTable.writeToDB(cb)
m.databaseID

TestTable.objects.filter(databaseID = m.id).update(cb, i1 = 1111, sm_s1 = "cba")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.