我想显示数据,但数据库与config / database中的设置数据库不同。但是,当我运行此代码时,它会给我错误。
这是我的代码:
import numpy as np
from libc.stdlib cimport malloc, calloc, realloc, free
def calculate_signed_areas(double[:,:,::1] triangles):
cdef:
int i, n
double area
double[::1] areas
double x0, x1, x2
double y0, y1, y2
n = triangles.shape[2]
areas = <double[:n]>malloc(n * sizeof(double))
for i in range(n):
x0 = triangles[0,0,i]
y0 = triangles[1,0,i]
x1 = triangles[0,1,i]
y1 = triangles[1,1,i]
x2 = triangles[0,2,i]
y2 = triangles[1,2,i]
area = (
+ x2 * (y0 - y1)
+ x0 * (y1 - y2)
+ x1 * (y2 - y0)
)/2.0
areas[i] = area
return np.asarray(areas)
我希望你能帮助我
答案 0 :(得分:0)
您可以在codeigniter中拥有多个具有不同组名的数据库连接组。
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "database_name";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
$db['default']['swap_pre'] = "";
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['otherdb']['hostname'] = "localhost";
$db['otherdb']['username'] = "root";
$db['otherdb']['password'] = "";
$db['otherdb']['database'] = "other_database_name";
$db['otherdb']['dbdriver'] = "mysql";
$db['otherdb']['dbprefix'] = "";
$db['otherdb']['pconnect'] = TRUE;
$db['otherdb']['db_debug'] = FALSE;
$db['otherdb']['cache_on'] = FALSE;
$db['otherdb']['cachedir'] = "";
$db['otherdb']['char_set'] = "utf8";
$db['otherdb']['dbcollat'] = "utf8_general_ci";
$db['otherdb']['swap_pre'] = "";
$db['otherdb']['autoinit'] = TRUE;
$db['otherdb']['stricton'] = FALSE;
$CI = & get_instance();
$CI->db = $this->load->database('otherdb', true);
答案 1 :(得分:0)
**Use this db config code:**
$db_name = 'test_db_name';
$db_user = 'root';
$db_password = '123456';
$config['dsn'] = "mysql:host=localhost;dbname=$db_name";
$config['hostname'] = "localhost";
$config['username'] = "$db_user";
$config['password'] = "$db_password";
$config['database'] = "$db_name";
$config['dbdriver'] = "pdo";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$this->db1 = $this->load->database($config, TRUE);