fieldtype

How to convert MySQL field types?

三世轮回 提交于 2020-06-27 15:13:44
问题 I have already come across the convert function. As I understand it, the basic syntax is: select convert(columnName, targetFieldType) as newColumnName from table; Running this command doesn't give me any errors, but when I check the data types they are unchanged. Even when I use commit; the data remains unchanged. In particular, I'm trying to convert data with long type to varchar. Any ideas? 回答1: The given SELECT query will return the value in the new type, but it doesn't change the field

Memory consumption of having a column LONGTEXT in MySQL database

淺唱寂寞╮ 提交于 2020-01-24 08:52:26
问题 I'm creating a log table in my MySQL database. One of the field will be only used in approximately 5% of the logs and will contains stack traces and others lengthy informations for the developers. I was considering using the LONGTEXT field but I was wondering if using this would make my database grow very quickly, even if this column is empty in 95% of the rows. So my question in clear, is there a memory consumption of having a LONGTEXT column even when this column is empty in most of the

How to specify column type(I need string) using pandas.to_csv method in Python?

扶醉桌前 提交于 2020-01-07 06:20:28
问题 import pandas as pd data = {'x':['011','012','013'],'y':['022','033','041']} Df = pd.DataFrame(data = data,type = str) Df.to_csv("path/to/save.csv") There result I've obtained seems as this 回答1: To achieve such result it will be easier to export directly to xlsx file, even without setting dtype of DataFrame. import pandas as pd writer = pd.ExcelWriter('path/to/save.xlsx') data = {'x':['011','012','013'],'y':['022','033','041']} Df = pd.DataFrame(data = data) Df.to_excel(writer,"Sheet1")

Symfony: Make a datetime form field really read-only

一笑奈何 提交于 2020-01-05 06:52:11
问题 I marked a datetime form field as read_only. Since this seams to have no effect I overruled the default twig template. This works fine. {% block datetime_widget %} {% if read_only %} {{ value.date.year }}-{{ value.date.month }}-{{ value.date.day }} {{ value.time.hour }}:{{ value.time.minute }} {% else %} {{ parent() }} {% endif %} {% endblock %} This is the form type I'm using: /** * @ORM\Entity */ abstract class BusinessClass { /** * @ORM\Column(type="datetime") * @var \DateTime */ private

Change type of varchar field to integer: “cannot be cast automatically to type integer”

久未见 提交于 2019-12-28 03:17:05
问题 I have a small table and a certain field contains the type " character varying ". I'm trying to change it to " Integer " but it gives an error that casting is not possible. Is there a way around this or should I just create another table and bring the records into it using a query. The field contains only integer values. 回答1: There is no implicit (automatic) cast from text or varchar to integer (i.e. you cannot pass a varchar to a function expecting integer or assign a varchar field to an

Which is the better data type for storing monetary values in Sharepoint 2010?

﹥>﹥吖頭↗ 提交于 2019-12-25 03:29:32
问题 In Sharepoint 2010, the "field types" (data types) for list items that could presumably be used for monetary values are Decimal and Currency. Normally, decimal is the preferred data type in C# for money. But what of this Currency type? Based on its name, it seems it may be the more suitable of the two. Is it? I could also use integer (where 1225 represents $12.25, for instance) or String (where "12.25" represents $12.25), but the first two mentioned (Decimal and Currency) would seem to be the

Symfony2 Data transformer on a Choice field type

这一生的挚爱 提交于 2019-12-13 00:49:19
问题 I am going step by step with the How to use Data Transformers The problem is that what if I want to do this with a Choice type? Which I dynamically populate with jQuery? I tested the example they provide (without creating a custom type..) and it works 100% with the text field type, but as soon as I change it to choice and give it empty choices it doesn't work, does this have to do with me populating the choices with jQuery after the page is loaded? Example Model [Select with the Model entity

Change type of varchar field to integer: “cannot be cast automatically to type integer”

三世轮回 提交于 2019-11-27 10:12:17
I have a small table and a certain field contains the type " character varying ". I'm trying to change it to " Integer " but it gives an error that casting is not possible. Is there a way around this or should I just create another table and bring the records into it using a query. The field contains only integer values. Craig Ringer There is no implicit (automatic) cast from text or varchar to integer (i.e. you cannot pass a varchar to a function expecting integer or assign a varchar field to an integer one), so you must specify an explicit cast using ALTER TABLE ... ALTER COLUMN ... TYPE ...

How to return field type from MySQL query?

二次信任 提交于 2019-11-27 03:11:30
问题 Simple question: How can I return the field type of a MySQL table. I know about describe or show column but I just want to return that single parameter. e.g.: SELECT fieldtype(mycol) FROM mytable # should return INT or integer for example 回答1: You can use SHOW FIELDS FROM tableName where Field ='nameOfField' This will return you result in format of Field Type Null Key Default Extra 回答2: You can get this from the information_schema database: select data_type from information_schema.columns