473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to insert null decimals / datetime into MYSQL from python?

I have the data file:

'Laura', 'Laura Ellenburg', '5342 Picklied Trout Lane', 'Nashville', 'TN', '38010', '2000-02-22', ' ', '454-56-768'

Notice the ' ' near the end.

I am using the python code:
Expand|Select|Wrap|Line Numbers
  1.   data = []
  2.   infile = open ("./BIGPVFC-ASC10e/Employee.asc", "r")
  3.   for line in infile:
  4.     line = line.rstrip("\n")
  5.     line = line.strip()
  6.     seq = line.split(", ")
  7.     for i in range(0,9):
  8.       seq[i] = seq[i].strip("'")
  9.     seq = tuple (seq)
  10.     data.append(seq)
  11.   infile.close()
  12.  
  13.   cursor.executemany ("""insert into PV_employee
  14.   (employeeid, employeename, employeeaddress, employeecity, employeestate, employeezip, employeedatehired, employeebirthdate, employeesupervisor)
  15.    values (%s, %s, %s, %s, %s, %s, %s, %s, %s)""", data)
  16.  
The table I have is:

create table PV_employee
(employeeid varchar(10) not null
,employeename varchar(25) null
,employeeaddress varchar(30) null
,employeecity varchar(20) null
,employeestate char(2) null
,employeezip varchar(10) null
,employeedatehired datetime null
,employeebirthdate datetime null
,employeesupervisor varchar(10) null
,primary key (employeeid)
);

where I get the error "Warning: Out of Range value for column ....."

In the case of null decimals I get "Warning: incorrect decimal value: ' ' for column ... "

I have tried change the ' ' to '', 'NULL', and NULL. None of these seem to work. Any suggestions?
Apr 9 '12 #1
0 1888

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark Davenport | last post by:
Hi, Here's my question: How do I pass a NULL value in a variable to a MySQL DB? Here's an overview of my problem: I have a PHP page that processes code, then inserts the code into a database....
11
by: grumfish | last post by:
I'm trying to add a row to a MySQL table using insert. Here is the code: connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", db="japanese") cursor = connection.cursor()...
2
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py...
2
by: Cathy Hui | last post by:
I am trying to install MySQL-Python 0.9.1 on my Solaris 8 system. The system has Python 2.3.3 and Mysql 4.0.21 installed. This is where I downloaded the distribution of the Mysql-python...
2
by: Cathy Hui | last post by:
Do u know why do i get the following message when trying to build the MySql-Python (1.2.0) on my Solaris 8 system? (with mysql 4.0.21 and python 2.4). thanks! error mesg: ld: fatal:...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
6
by: FatboyCanteen | last post by:
When I using dataset to append a null value to the datetime field. It throw a error -> can not convert db.null to system.date Can there is any standard to pass a Null value to the DateTime...
0
by: Olivier Langlois | last post by:
Hi, I have tried to install MySQL-python-1.2.1_p2 under Windows XP with Python 2.4.3 and I get some problems. 1- I get this warning when I run setup.py build: ...
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
2
by: dmorand | last post by:
I have this query that I'm using in coldfusion: Insert into ps_manager_employee_ids (manager_emplid,emp_id,last_name,first_name,hire_dt,rehire_dt,emp_status,union_status) values...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.