
Saludos a todos


Código
cdef extern from "pytiodbc.cpp": openconn(char *dsn, char *user, char *pwd) def connect(dsn,user,pwd) python son de tipo str if not isinstance(dsn,unicode): if not isinstance(dsn,str): raise ValueError("'dsn' requires text input, got %s" % type(text)) udsn=dsn.encode('UTF-8') if not isinstance(user,unicode): if not isinstance(user,str): raise ValueError("'user' requires text input, got %s" % type(text)) uuser=user.encode('UTF-8') if not isinstance(pwd,unicode): if not isinstance(pwd,str): raise ValueError("'user' requires text input, got %s" % type(text)) upwd=pwd.encode('UTF-8') #Llamamos a la función definida en pytiodbc.cpp ret=openconn(udsn,uuser,upwd)
el archivo pytiodbc.cpp que importo es uno realizado por mi para probar si podía llamar la funcion desde el C++, anexo el código.
Código
#include "tiodbc.hpp" #include <iostream> using namespace std; bool openconn(char *dsn, char *user, char *pwd); bool openconn(char *dsn, char *user, char *pwd){ // Crea la conexión al ODBC tiodbc::connection my_connection(dsn, user, pwd); // Verifica que la conexión sea éxitosa if (my_connection.connected()) return true; else return false; // Se Desconecta my_connection.disconnect(); }
lo que deseo es poder llamar esa función desde Python

Código
import sys import os import pytiodbc print "Ejemplo conectar a Base de datos" resp = pytiodbc.connect ("DSN=Test","Test","Test") print resp os.system("pause")
Quisiera saber si esta manera es correcta ó por obligatoriedad tendría que útilizar el Swig ó Boost
