Comments (3)
同时,这个设计特别奇怪
dbPath="dfs://db_value_date"
if s.existsDatabase(dbPath):
s.dropDatabase(dbPath)
dates=np.array(pd.date_range(start='20120101', end='20120110'), dtype="datetime64[D]")
db = s.database(dbName='mydb', partitionType=keys.VALUE, partitions=dates,dbPath=dbPath)
df = pd.DataFrame({'datetime':np.array(['2012-01-01T00:00:00', '2012-01-02T00:00:00'], dtype='datetime64'), 'sym':['AA', 'BB'], 'val':[1,2]})
t = s.table(data=df)
db.createPartitionedTable(table=t, tableName='pt', partitionColumns='datetime').append(t)
re=s.loadTable(tableName='pt', dbPath=dbPath).toDF()
为什么建表的时候需要传入data,一般的应用场景下都是先create table再进行数据写入,难道每次想写入数据的时候都创建一个新的表???
from api_python3.
dbPath="dfs://db_value_date"
if s.existsDatabase(dbPath):
s.dropDatabase(dbPath)
dates=np.array(pd.date_range(start='20120101', end='20120110'), dtype="datetime64[D]")
db = s.database(dbName='mydb', partitionType=keys.VALUE, partitions=dates,dbPath=dbPath)
df = pd.DataFrame({'datetime':np.array(['2012-01-01T00:00:00', '2012-01-02T00:00:00'], dtype='datetime64'), 'sym':['AA', 'BB'], 'val':[1,2]})
t = s.table(data=df)
db.createPartitionedTable(table=t, tableName='pt', partitionColumns='datetime').append(t)
re=s.loadTable(tableName='pt', dbPath=dbPath).toDF()
另一个奇怪的点在于, database为什么要指定分区。。数据不应该是和表挂钩吗?一个表期望使用时间D进行分区?一个期望使用股票板块plate进行分区,另一个使用股票id进行分区
归属同一个数据库的时候难道要分别设置分区吗???为啥要和库挂钩??
from api_python3.
问题 1: 您方便提供一下报错信息吗?
问题 2:建表语句为 db.createPartitionedTable(table=t, tableName='pt', partitionColumns='datetime'), 其中 table 参数提供的表只是作为创建表的表结构,它可以是一个空表也可以是个有数据的表,如果有数据是不会写入创建表的,真正写入数据的部分在 append(t)。如果表不存在,可以先创建一个表,如 pt = db.createPartitionedTable(table=t, tableName='pt', partitionColumns='datetime'),如果是已经存在的表,则先通过 pt = s.loadTable 加载 pt 表对象。后续可以通过 pt.append(t) 或者其他写入函数向该表写入数据,不需要创建一个新表。
问题 3:数据库分区有利于并行计算,增加可用性等等,关于数据库分区的说明可以参考教程:https://gitee.com/dolphindb/Tutorials_CN/blob/master/database.md。
相同分区方案的分区表可以存在同一个数据库。如果您希望数据表不分区可以使用维度表(通过函数 createTable 创建,此时您数据库可以任意设置一个分区方案),关于维度表的说明可以参考 https://www.dolphindb.cn/cn/help/130/FunctionsandCommands/FunctionReferences/c/createTable.html
from api_python3.
Related Issues (15)
- 异步接口
- pip install dolphindb ERROR HOT 3
- 对python3.11的支持 HOT 9
- 利用 tableAppender 插入数据会报 Warning HOT 2
- py api有source code么? HOT 2
- 数据类型为Object传入输出时确推断为double????? HOT 2
- 请问是否有添加异步支持的计划?
- mac系统无法安装dolphindb的python接口包 HOT 4
- dolphindb.type_util模块找不到 HOT 1
- 无法安装 pip install dolphindb HOT 5
- Does DolphinDB support User Defined Function? HOT 1
- 高版本支持 HOT 5
- 树莓派里运行的docker版Ubuntu无法安装dolphindb的python包 HOT 1
- 通过pip 安装 报DLL的问题.python版本3.88 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api_python3.