Python中文
首页
教程
问答
标签
搜索
登录
注册
使用Web2py/Pydal将字段定义为无符号整数
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p><strong>是否可以使用无符号整数<code>Field</code>定义web2py模型?如果是,可以如何进行?</strong></p> <p>底层数据库是MySQL,下面是等效的<code>CREATE TABLE</code>语句</p> <pre class="lang-sql prettyprint-override"><code>CREATE TABLE `t` ( `id` int(11) NOT NULL AUTO_INCREMENT, `value` int(11) unsigned DEFAULT NULL, PRIMARY KEY (`id`) ) ; </code></pre> <p>我做了三次尝试,都没有成功。以下是这些尝试的片段</p> <pre class="lang-py prettyprint-override"><code>db.define_table('t', Field('value', 'integer unsigned')) </code></pre> <pre class="lang-py prettyprint-override"><code>db.define_table('t', Field('value', 'integer', options=['unsigned'])) </code></pre> <pre class="lang-py prettyprint-override"><code>db.define_table('t', Field('value', 'integer', options=['UNSIGNED'])) </code></pre> <p>我在<a href="http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-constructor" rel="nofollow noreferrer">web2py</a>或<a href="https://pydal.readthedocs.io/en/latest/index.html#pydal.objects.Field" rel="nofollow noreferrer">pydal</a>文档中都没有提到无符号整数。当然,web2py或pydal都可能不支持无符号整数。我使用的是web2py版本2.20.4-stable+timestamp.2020.05.02.22.03.36、pydal版本20200502.2和MySQL版本5.7.25</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我认为您需要在字段上定义自定义的_限定符:</p> <pre><code>Field('value', 'integer', custom_qualifier='UNSIGNED') </code></pre> <p>它只是在迁移时附加到字段定义中</p> <p>这会降低项目的可移植性,因为例如,在PostgreSQL或MSSQL中没有未签名的int</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
2 回答
如何在python中从数据帧列表中删除引号
1 回答
如何在python中从数据帧创建列表
9 回答
如何在Python中从数据帧创建嵌套的JSON
2 回答
如何在Python中从数据帧显示wordcloud
5 回答
如何在Python中从数据帧的时间戳中删除字符
6 回答
如何在Python中从数据帧绘制简单绘图?
5 回答
如何在python中从数据帧行提取具有特定长度的范围?
3 回答
如何在python中从数据帧设置dict中的值
2 回答
如何在Python中从数据库中获得一个结果
6 回答
如何在python中从数据框中绘制分类条形图
4 回答
如何在Python中从数据框中选择特定细节?
2 回答
如何在python中从数据集中删除unicode
2 回答
如何在python中从数据集中删除某些数值?
8 回答
如何在python中从数据集中选择行
6 回答
如何在Python中从数组中删除元素
10 回答
如何在python中从数组中删除单个倒逗号?
10 回答
如何在python中从数组中删除对象?
4 回答
如何在python中从数组中删除引号
5 回答
如何在python中从数组中删除所有最小值
5 回答