def connect(self): if self.rdbms == 'mssql': import socket #( To get the computer name for a SQL Server instance. import ipymssql #( Custom IronPython .NET Data Provider for SQL Server Instance = socket.gethostname() + r"\SILFW" Database = 'TestLangProj' conStr = 'Data Source=%s; Initial Catalog=%s; Integrated Security=True' % (Instance, Database) con = ipymssql.connect(conStr) elif self.rdbms == 'fb' or self.rdbms == 'firebird': import kinterbasdb #( http://kinterbasdb.sourceforge.net #( kinterbasdb must be initialized for life to be happy. See #( "Incompatibilities" at the top of: #( #( http://kinterbasdb.sourceforge.net/dist_docs/usage.html #( #( The default for kinterbasdb.init is only for backward compatibility. #( The reasons for this are written up at: #( #( http://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_is_mxdatetime_required #( #( The ideal is to use type_conv=200 kinterbasdb.init(type_conv=200) con = kinterbasdb.connect( dsn = 'C:\Program Files\Firebird_2_0\Data\TESTLANGPROJ.FDB', user = "******", password = "******", charset = 'UTF8', dialect = 3) return con
def testExecCreateInsertSelectDrop(self): cur.execute("create table tablex (col1 int)") cur.execute("insert into tablex values (1)") cur.execute("select * from tablex") rows = cur.fetchall() print "testExecCreateInsertSelectDrop(): rows from tablex: ", rows self.assertEqual(1, rows[0][0], "The first row should have a column with a value 1") cur.execute("drop table tablex") if __name__ == '__main__': #TODO: make conStr and database parameters. instance = socket.gethostname() + r"<named instance>" database = '<database name>' conStr = 'Data Source=%s; Initial Catalog=%s; Integrated Security=True' % ( instance, database) con = ipymssql.connect(conStr) cur = con.cursor() #==( Run the unit tests )==# unittest.main() cur.Close() con.Close()
print "callproc(), fetchall() results: ", rows self.assertEqual("Test2", rows[0][0], "The first row should have a column with a value 'Test2'") def testExecCreateInsertSelectDrop(self): cur.execute("create table tablex (col1 int)") cur.execute("insert into tablex values (1)") cur.execute("select * from tablex") rows = cur.fetchall() print "testExecCreateInsertSelectDrop(): rows from tablex: ", rows self.assertEqual(1, rows[0][0], "The first row should have a column with a value 1") cur.execute("drop table tablex") if __name__ == '__main__': #TODO: make conStr and database parameters. instance = socket.gethostname() + r"<named instance>" database = '<database name>' conStr = 'Data Source=%s; Initial Catalog=%s; Integrated Security=True' % (instance, database) con = ipymssql.connect(conStr) cur = con.cursor() #==( Run the unit tests )==# unittest.main() cur.Close() con.Close()