python sqlite3 报错

今天给一台服务器(centos5.2 和 python2.7.3)装环境,import sqlite3报错。根据以前的经验,重新编译python就行了。直接编译,结果在make时报错:

Failed to build these modules:
_sqlite3

在网上查了一下解决办法:编辑源码下的connection.c这个文件

vi Python-2.7.3/Modules/_sqlite/connection.c

#include "cache.h"
#include "module.h"
#include "connection.h"
#include "statement.h"
#include "cursor.h"
#include "prepare_protocol.h"
#include "util.h"
#include "sqlitecompat.h"

#include "pythread.h"

#define ACTION_FINALIZE 1
#define ACTION_RESET 2

#if SQLITE_VERSION_NUMBER >= 3003008
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define HAVE_LOAD_EXTENSION
#endif
#endif


下面添加
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;

再次make,没有报错。


附注:

解决问题是借鉴了这个博文:

http://blog.hijiam.com/page/2



你可能感兴趣的:(sqlite,python,centos,Build,action,import)