EdgeDB Python驱动程序
edgedb的Python项目详细描述
edgedb python是python的官方edgedb驱动程序。 它提供了阻塞IO和异步IO实现。
库需要Python3.6或更高版本。
文档
可以找到项目文档 here。
安装
这个库在pypi上可用。使用pip安装:
$ pip install edgedb
基本用法
importdatetimeimportedgedbdefmain():# Establish a connection to an existing database named "test"# as an "edgedb" user.conn=edgedb.connect('edgedb://edgedb@localhost/test')# Create a User object typeconn.execute(''' CREATE TYPE User { CREATE REQUIRED PROPERTY name -> str; CREATE PROPERTY dob -> local_date; } ''')# Insert a new User objectconn.fetchall(''' INSERT User { name := <str>$name, dob := <local_date>$dob } ''',name='Bob',dob=datetime.date(1984,3,1))# Select User objects.user_set=conn.fetchall('SELECT User {name, dob} FILTER .name = <str>$name',name='Bob')# *user_set* now contains# Set{Object{name := 'Bob', dob := datetime.date(1984, 3, 1)}}# Close the connection.conn.close()if__name__=='__main__':main()
许可证
EdgeDB Python是在Apache2.0许可下开发和分发的。