A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/python__ncbi__dbapi__test_8cpp_source.html below:

NCBI C++ ToolKit: src/dbapi/lang_bind/python/tests/python_ncbi_dbapi_test.cpp Source File

64  string

sybase_version;

66 #if defined(NCBI_OS_MSWIN) 67

sybase_version =

"12.5"

;

72

sybase_version =

env

.Get(

"SYBASE"

);

75

sybase_version = dir_entry.

GetPath

();

77

sybase_version = sybase_version.substr(

78

sybase_version.find_last_of(

'/'

) + 1

82  return

sybase_version;

101  string cmd

=

string

(

"cursor.execute('''"

) +

sql

+

"''') \n"

;

108 #define ALL_DRIVERS "ctlib"

, "ftds", "ftds100", "ftds14", "odbc"

109 #if defined(NCBI_OS_MSWIN) 110 #define DEF_SERVER "MSDEV1" 111 #define DEF_DRIVER "ftds" 113 #define DEF_SERVER "THALBERG" 114 #define DEF_DRIVER "ftds" 117

arg_desc->AddDefaultKey(

"S"

,

"server"

,

118  "Name of the SQL server to connect to"

,

121

arg_desc->AddDefaultKey(

"dr"

,

"driver"

,

122  "Name of the DBAPI driver to use"

,

127

arg_desc->AddDefaultKey(

"U"

,

"username"

,

131

arg_desc->AddDefaultKey(

"P"

,

"password"

,

134

arg_desc->AddDefaultKey(

"D"

,

"database"

,

135  "Name of the database to connect"

,

138

arg_desc->AddOptionalKey(

"V"

,

"version"

,

139  "TDS protocol version"

,

148  double

syb_client_ver = 0.0;

151  if

(!syb_client_ver_str.empty()) {

159

parser->AddSymbol(

"SYBASE_ClientVersion"

, syb_client_ver);

163 #ifdef HAVE_LIBSYBASE 164

parser->AddSymbol(

"HAVE_Sybase"

,

true

);

166

parser->AddSymbol(

"HAVE_Sybase"

,

false

);

170

parser->AddSymbol(

"HAVE_ODBC"

,

true

);

172

parser->AddSymbol(

"HAVE_ODBC"

,

false

);

178

parser->AddSymbol(

"DRIVER_ftds"

,

180

parser->AddSymbol(

"DRIVER_odbc"

,

GetArgs

().GetDriverName() ==

"odbc"

);

181

parser->AddSymbol(

"DRIVER_ctlib"

,

GetArgs

().GetDriverName() ==

"ctlib"

);

190  env

.Set(

"PYTHONPATH"

,

env

.Get(

"CFG_BIN"

));

192  string

lib_dir =

env

.Get(

"CFG_LIB"

);

193  env

.Set(

"PYTHONPATH"

, lib_dir);

194  env

.Set(

"LD_LIBRARY_PATH"

, lib_dir +

":"

+

env

.Get(

"LD_LIBRARY_PATH"

));

199  string

connection_args(

GetArgs

().GetDriverName() +

"', '"

+

200  GetArgs

().GetServerTypeStr() +

"', '"

+

201  GetArgs

().GetServerName() +

"', '"

+

202  GetArgs

().GetDatabaseName() +

"', '"

+

203  GetArgs

().GetUserName() +

"', '"

+

204  GetArgs

().GetUserPassword() );

206  string

connection_str(

"connection = dbapi.connect('"

+

209  string

conn_simple_str(

"conn_simple = dbapi.connect('"

+

213  ExecuteStr

(

"import python_ncbi_dbapi as dbapi\n"

);

215  ExecuteStr

(

"dbapi.release_global_lock(True)"

);

219  ExecuteStr

(

"cursor_simple = conn_simple.cursor() \n"

);

220  ExecuteStr

(

"cursor_simple.execute('CREATE TABLE #t ( vkey int )') \n"

);

223  "'CREATE TABLE #t2 ( " 224  " int_val int null, " 226  " vc1900_field varchar(1900) null, " 227  " text_val text null, " 228  " image_val image null)') \n" 240  ExecuteStr

(

"version = dbapi.__version__ \n"

);

241  ExecuteStr

(

"apilevel = dbapi.apilevel \n"

);

242  ExecuteStr

(

"threadsafety = dbapi.threadsafety \n"

);

243  ExecuteStr

(

"paramstyle = dbapi.paramstyle \n"

);

248  ExecuteStr

(

"cursor = connection.cursor()\n"

);

249  ExecuteStr

(

"cursor2 = conn_simple.cursor()\n"

);

251 #if PY_VERSION_HEX >= 0x02040000 252  ExecuteStr

(

"date_val = dbapi.Date(1, 1, 1)\n"

);

253  ExecuteStr

(

"time_val = dbapi.Time(1, 1, 1)\n"

);

254  ExecuteStr

(

"timestamp_val = dbapi.Timestamp(1, 1, 1, 1, 1, 1)\n"

);

256  ExecuteStr

(

"binary_val = dbapi.Binary('Binary test')\n"

);

258  ExecuteStr

(

"cursor.execute('select qq = 57 + 33') \n"

);

260  ExecuteStr

(

"cursor.execute('select qq = 57.55 + 0.0033')\n"

);

262  ExecuteStr

(

"cursor.execute('select qq = GETDATE()')\n"

);

264  ExecuteStr

(

"cursor.execute('select name, type from sysobjects')\n"

);

267  ExecuteStr

(

"rowcount = cursor.rowcount \n"

);

268  ExecuteStr

(

"cursor.execute('select name, type from sysobjects where type = @type_par', {'type_par':'S'})\n"

);

270  ExecuteStr

(

"cursor.executemany('select name, type from sysobjects where type = @type_par', [{'type_par':'S'}, {'type_par':'D'}])\n"

);

277  ExecuteStr

(

"cursor2.execute('select qq = 57 + 33')\n"

);

289  const string

connection_args(

GetArgs

().GetDriverName() +

"', '"

+

290  GetArgs

().GetServerTypeStr() +

"', '"

+

291  GetArgs

().GetServerName() +

"', '"

+

292  GetArgs

().GetDatabaseName() +

"', '"

+

293  GetArgs

().GetUserName() +

"', '"

+

294  GetArgs

().GetUserPassword() );

298  const string

connection_str(

"tmp_connection = dbapi.connect('"

+

301  const string

connection2_str(

"tmp_connection2 = dbapi.connect('"

+

304  const string

connection3_str(

"tmp_connection3 = dbapi.connect('"

+

318  ExecuteStr

(

"tmp_cursor = tmp_connection.cursor()\n"

);

319  ExecuteStr

(

"tmp_cursor.execute('SET NOCOUNT ON')\n"

);

326  ExecuteStr

(

"tmp_cursor = tmp_connection.cursor()\n"

);

327  ExecuteStr

(

"tmp_cursor.execute('SELECT @@version')\n"

);

330  ExecuteStr

(

"tmp_cursor2 = tmp_connection2.cursor()\n"

);

331  ExecuteStr

(

"tmp_cursor2.execute('SELECT @@version')\n"

);

334  ExecuteStr

(

"tmp_cursor3 = tmp_connection3.cursor()\n"

);

335  ExecuteStr

(

"tmp_cursor3.execute('SELECT @@version')\n"

);

339  ExecuteStr

(

"tmp_cursor = tmp_connection.cursor()\n"

);

340  ExecuteStr

(

"tmp_cursor.execute('SELECT @@version')\n"

);

342  ExecuteStr

(

"tmp_cursor2 = tmp_connection2.cursor()\n"

);

343  ExecuteStr

(

"tmp_cursor2.execute('SELECT @@version')\n"

);

345  ExecuteStr

(

"tmp_cursor3 = tmp_connection3.cursor()\n"

);

346  ExecuteStr

(

"tmp_cursor3.execute('SELECT @@version')\n"

);

359  const string

connection_str(

"tmp_connection = dbapi.connect('"

+

361  "', {'client_charset':'UTF-8'})\n"

);

366  ExecuteStr

(

"tmp_cursor = tmp_connection.cursor()\n"

);

367  ExecuteStr

(

"tmp_cursor.execute('SET NOCOUNT ON')\n"

);

377  ExecuteStr

(

"cursor = connection.cursor()\n"

);

378  ExecuteStr

(

"cursor.execute('select qq = 57 + 33')\n"

);

386  ExecuteStr

(

"cursor = connection.cursor()\n"

);

387  ExecuteStr

(

"cursor.execute('select name, type from sysobjects')\n"

);

403  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

409  ExecuteStr

(

"cursor.execute('SELECT name FROM syscolumns WHERE id = CONVERT(INT, @id)', {'@id':None})\n"

);

416  ExecuteStr

(

"cursor.execute('SELECT name, type FROM sysobjects WHERE type = @type_par', {'@type_par':'S'})\n"

);

424  ExecuteStr

(

"cursor.execute('DELETE FROM #t2')\n"

);

425  ExecuteStr

(

"seq_align = 254 * '-' + 'X' \n"

);

426  ExecuteStr

(

"cursor.execute('INSERT INTO #t2(vc1900_field) VALUES(@tv)', {'@tv':seq_align})\n"

);

427  ExecuteStr

(

"cursor.execute('SELECT vc1900_field FROM #t2') \n"

);

428  ExecuteStr

(

"if len(cursor.fetchone()[0]) != 255 : raise Exception('Invalid string length.') \n"

);

434  ExecuteStr

(

"seq_align = 254 * '-' + 'X' + 100 * '-'\n"

);

435  ExecuteStr

(

"if len(seq_align) != 355 : raise Exception('Invalid string length.') \n"

);

436  ExecuteStr

(

"cursor.execute('INSERT INTO #t2(vc1900_field) VALUES(@tv)', {'@tv':seq_align})\n"

);

437  ExecuteSQL

(

"SELECT vc1900_field FROM #t2"

);

441  ExecuteStr

(

"if len(record[0]) != 355 : raise Exception('Invalid string length.') \n"

);

443  ExecuteStr

(

"cursor.execute('DELETE FROM #t2')\n"

);

444  ExecuteStr

(

"seq_align = 254 * '-' + 'X' + 100 * '-'\n"

);

445  ExecuteStr

(

"if len(seq_align) != 355 : raise Exception('Invalid string length.') \n"

);

446  ExecuteStr

(

"cursor.execute('INSERT INTO #t2(text_val) VALUES(@tv)', {'@tv':seq_align})\n"

);

447  ExecuteStr

(

"cursor.execute('SELECT text_val FROM #t2') \n"

);

448  ExecuteStr

(

"record = cursor.fetchone() \n"

);

450  ExecuteStr

(

"if len(record[0]) != 355 : raise Exception('Invalid string length.') \n"

);

455  ExecuteStr

(

"cursor.execute('select cast(@dt as datetime)', (datetime.datetime(2010,1,1,12,1,2,50000),)) \n"

);

456  ExecuteStr

(

"dt = cursor.fetchone()[0] \n"

);

458  ExecuteStr

(

"if dt.year != 2010 or dt.month != 1 or dt.day != 1 " 459  "or dt.hour != 12 or dt.minute != 1 or dt.second != 2 " 460  "or dt.microsecond != 50000: " 461  "raise Exception('Invalid datetime returned: ' + str(dt)) \n"

);

469  ExecuteStr

(

"sql_ins = 'INSERT INTO #t(vkey) VALUES(@value)' \n"

);

470  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

471  ExecuteStr

(

"cursor.executemany(sql_ins, [ {'@value':value} for value in range(1, 11) ]) \n"

);

472  ExecuteStr

(

"cursor.executemany(sql_ins, [ {'value':value} for value in range(1, 11) ]) \n"

);

481  ExecuteStr

(

"sql_ins = 'INSERT INTO #t(vkey) VALUES(@value)' \n"

);

482  ExecuteStr

(

"sql_sel = 'SELECT * FROM #t' \n"

);

483  ExecuteStr

(

"cursor = conn_simple.cursor() \n"

);

486  ExecuteStr

(

"cursor.execute('BEGIN TRANSACTION') \n"

);

487  ExecuteStr

(

"cursor.executemany(sql_ins, [ {'@value':value} for value in range(1, 11) ]) \n"

);

494  ExecuteStr

(

"cursor.execute('ROLLBACK TRANSACTION') \n"

);

495  ExecuteStr

(

"cursor.execute('BEGIN TRANSACTION') \n"

);

498  ExecuteStr

(

"cursor.executemany(sql_ins, [ {'@value':value} for value in range(1, 11) ]) \n"

);

501  ExecuteStr

(

"cursor.execute('COMMIT TRANSACTION') \n"

);

510  s_Engine

->

ExecuteFile

(

"E:\\home\\nih\\c++\\src\\dbapi\\lang_bind\\python\\samples\\sample9.py"

);

518  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

524  ExecuteStr

(

"print(cursor.callproc('SampleProc3', {'@id':1, '@f':2.0, '@o':0}))\n"

);

527  " print(cursor.fetchall())" 532  ExecuteStr

(

"print(cursor.callproc('DBAPI_Sample..SampleProc3', {'@id':1, '@f':2.0, '@o':0}))"

);

535  " print(cursor.fetchall())" 540  ExecuteStr

(

"print(cursor.callproc('DBAPI_Sample.dbo.SampleProc3', {'@id':1, '@f':2.0, '@o':0}))\n"

);

543  " print(cursor.fetchall() )" 548  ExecuteStr

(

"db_pipe = dbapi.connect('ftds', 'MSSQL','GPIPE_META', 'GPIPE_META', 'anyone', 'allowed') \n"

);

549  ExecuteStr

(

"cursor_pipe = db_pipe.cursor()\n"

);

551  ExecuteStr

(

"print(cursor_pipe.callproc('test', {'@myparam':1}))\n"

);

554  " print(cursor.fetchall() )" 559  ExecuteStr

(

"cursor_test = conn_simple.cursor()\n"

);

561  ExecuteStr

(

"while cursor_test.nextset() : \n" 562  " print(cursor_test.fetchall() )" 567  ExecuteStr

(

"print(cursor.callproc('sp_databases'))\n"

);

569  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

),

573  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

),

581  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

583  ExecuteStr

(

"print(cursor.callproc('sp_server_info'))\n"

);

585  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

590  ExecuteStr

(

"print(cursor.callproc('SampleProc3', {'@id':1, '@f':2.0, '@o':0}))\n"

);

593  " print(cursor.fetchall() )" 604  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

608  ExecuteStr

(

"cursor.execute('execute sp_databases')\n"

);

610  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

611  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

614  ExecuteStr

(

"cursor.execute('exec sp_server_info 1')\n"

);

616  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

),

620  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

),

624  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

625  ExecuteStr

(

"cursor.execute('exec sp_server_info 2')\n"

);

630  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

631  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

640  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

644  ExecuteStr

(

"cursor.execute('execute sp_databases')\n"

);

646  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

647  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

650  ExecuteStr

(

"cursor.callproc('sp_server_info', [1])\n"

);

652  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

),

656  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

),

660  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

661  ExecuteStr

(

"cursor.callproc('sp_server_info', [2])\n"

);

666  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

667  ExecuteStr

(

"rc = cursor.get_proc_return_status()\n"

);

677  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

680  "CREATE TABLE #Overlaps ( \n" 681  " pairId int NOT NULL , \n" 682  " overlapNum smallint NOT NULL , \n" 683  " start1 int NOT NULL , \n" 684  " start2 int NOT NULL , \n" 685  " stop1 int NOT NULL , \n" 686  " stop2 int NOT NULL , \n" 687  " orient char (2) NOT NULL , \n" 688  " gaps int NOT NULL , \n" 689  " mismatches int NOT NULL , \n" 690  " adjustedLen int NOT NULL , \n" 691  " length int NOT NULL , \n" 692  " contained tinyint NOT NULL , \n" 693  " seq_align text NULL , \n" 694  " merged_sa char (1) NOT NULL , \n" 706  "Seq-align ::= { type partial, dim 2, score " 707  "{ { id str \"score\", value int 6771 }, { id str " 708  "\"e_value\", value real { 0, 10, 0 } }, { id str " 709  "\"bit_score\", value real { 134230121751674, 10, -10 } }, " 710  "{ id str \"num_ident\", value int 7017 } }, segs denseg " 711  "{ dim 2, numseg 3, ids { gi 3021694, gi 3924652 }, starts " 712  "{ 6767, 32557, 6763, -1, 0, 25794 }, lens { 360, 4, 6763 }, " 713  "strands { minus, minus, minus, minus, minus, minus } } }"

;

718  "INSERT INTO #Overlaps VALUES( \n" 719  "1, 1, 0, 25794, 7126, 32916, '--', 1, 21, 7124, 7127, 0, \n"

;

727  sql

=

"SELECT * FROM #Overlaps"

;

729  ExecuteStr

(

"record = cursor.fetchone() \n"

);

732  "raise Exception('Invalid number of columns.') \n" 735  ExecuteStr

(

"if len(record[12]) != len(long_str) : " 736  "raise Exception('Invalid string size: ') \n" 747  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

754  "Seq-align ::= { type partial, dim 2, score " 755  "{ { id str \"score\", value int 6771 }, { id str " 756  "\"e_value\", value real { 0, 10, 0 } }, { id str " 757  "\"bit_score\", value real { 134230121751674, 10, -10 } }, " 758  "{ id str \"num_ident\", value int 7017 } }, segs denseg " 759  "{ dim 2, numseg 3, ids { gi 3021694, gi 3924652 }, starts " 760  "{ 6767, 32557, 6763, -1, 0, 25794 }, lens { 360, 4, 6763 }, " 761  "strands { minus, minus, minus, minus, minus, minus } } }"

;

766  sql

=

"cursor.execute('INSERT INTO #t2(vc1900_field, text_val, image_val) VALUES(@vcv, @tv, @iv)', "

;

767  sql

+=

" {'@vcv':long_str, '@tv':long_str, '@iv':dbapi.Binary(long_str)} ) \n"

;

773  sql

=

"SELECT vc1900_field, text_val, image_val FROM #t2"

;

775  ExecuteStr

(

"record = cursor.fetchone() \n"

);

779  ExecuteStr

(

"if len(record[0]) != len(long_str) : " 780  "raise Exception('Invalid string size: ') \n" 782  ExecuteStr

(

"if len(record[1]) != len(long_str) : " 783  "raise Exception('Invalid string size: ') \n" 785  ExecuteStr

(

"if len(record[2]) != len(long_str) : " 786  "raise Exception('Invalid string size: ') \n" 794  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

797

BOOST_CHECK_THROW(

ExecuteSQL

(

"raiserror 99999 'error msg'\n"

),

string

);

821  " raise dbapi.Warning(\"Oops ...\") \n" 822  "except dbapi.Warning as inst: \n" 823  " print(\"%s is OK!\" % type(inst))\n" 829  " raise dbapi.Warning(\"Oops ...\") \n" 830  "except Exception as inst: \n" 831  " print(\"%s is OK!\" % type(inst))\n" 839  " raise dbapi.Error(\"Oops ...\") \n" 840  "except dbapi.Error as inst: \n" 841  " print(\"%s is OK!\" % type(inst))\n" 847  " raise dbapi.Error(\"Oops ...\") \n" 848  "except Exception as inst: \n" 849  " print(\"%s is OK!\" % type(inst))\n" 857  " raise dbapi.InterfaceError(\"Oops ...\") \n" 858  "except dbapi.InterfaceError as inst: \n" 859  " print(\"%s is OK!\" % type(inst))\n" 865  " raise dbapi.InterfaceError(\"Oops ...\") \n" 866  "except dbapi.Error as inst: \n" 867  " print(\"%s is OK!\" % type(inst))\n" 875  " raise dbapi.DatabaseError(\"Oops ...\") \n" 876  "except dbapi.DatabaseError as inst: \n" 877  " print(\"%s is OK!\" % type(inst))\n" 883  " raise dbapi.DatabaseError(\"Oops ...\") \n" 884  "except dbapi.Error as inst: \n" 885  " print(\"%s is OK!\" % type(inst))\n" 891  " cursor.execute('SELECT * FROM wrong_table') \n" 892  "except dbapi.DatabaseError as inst: \n" 893  " print(type(inst), inst.srv_errno, inst.srv_msg)\n" 901  " raise dbapi.DataError(\"Oops ...\") \n" 902  "except dbapi.DataError as inst: \n" 903  " print(\"%s is OK!\" % type(inst))\n" 909  " raise dbapi.DataError(\"Oops ...\") \n" 910  "except dbapi.DatabaseError as inst: \n" 911  " print(\"%s is OK!\" % type(inst))\n" 919  " raise dbapi.OperationalError(\"Oops ...\") \n" 920  "except dbapi.OperationalError as inst: \n" 921  " print(\"%s is OK!\" % type(inst))\n" 927  " raise dbapi.OperationalError(\"Oops ...\") \n" 928  "except dbapi.DatabaseError as inst: \n" 929  " print(\"%s is OK!\" % type(inst))\n" 937  " raise dbapi.IntegrityError(\"Oops ...\") \n" 938  "except dbapi.IntegrityError as inst: \n" 939  " print(\"%s is OK!\" % type(inst))\n" 945  " raise dbapi.IntegrityError(\"Oops ...\") \n" 946  "except dbapi.DatabaseError as inst: \n" 947  " print(\"%s is OK!\" % type(inst))\n" 955  " raise dbapi.InternalError(\"Oops ...\") \n" 956  "except dbapi.InternalError as inst: \n" 957  " print(\"%s is OK!\" % type(inst))\n" 963  " raise dbapi.InternalError(\"Oops ...\") \n" 964  "except dbapi.DatabaseError as inst: \n" 965  " print(\"%s is OK!\" % type(inst))\n" 973  " raise dbapi.ProgrammingError(\"Oops ...\") \n" 974  "except dbapi.ProgrammingError as inst: \n" 975  " print(\"%s is OK!\" % type(inst))\n" 981  " raise dbapi.ProgrammingError(\"Oops ...\") \n" 982  "except dbapi.DatabaseError as inst: \n" 983  " print(\"%s is OK!\" % type(inst))\n" 991  " raise dbapi.NotSupportedError(\"Oops ...\") \n" 992  "except dbapi.NotSupportedError as inst: \n" 993  " print(\"%s is OK!\" % type(inst))\n" 999  " raise dbapi.NotSupportedError(\"Oops ...\") \n" 1000  "except dbapi.DatabaseError as inst: \n" 1001  " print(\"%s is OK!\" % type(inst))\n" 1011  " raise dbapi.Warning(\"Oops ...\") \n" 1012  "except dbapi.Warning as inst: \n" 1013  " print(type(inst), inst)\n" 1020  " raise dbapi.Error(\"Oops ...\") \n" 1021  "except dbapi.Error as inst: \n" 1022  " print(type(inst), inst)\n" 1029  " raise dbapi.InterfaceError(\"Oops ...\") \n" 1030  "except dbapi.InterfaceError as inst: \n" 1031  " print(type(inst), inst)\n" 1038  " raise dbapi.DatabaseError(\"Oops ...\") \n" 1039  "except dbapi.DatabaseError as inst: \n" 1040  " print(type(inst), inst)\n" 1047  " raise dbapi.DataError(\"Oops ...\") \n" 1048  "except dbapi.DataError as inst: \n" 1049  " print(type(inst), inst)\n" 1056  " raise dbapi.OperationalError(\"Oops ...\") \n" 1057  "except dbapi.OperationalError as inst: \n" 1058  " print(type(inst), inst)\n" 1065  " raise dbapi.IntegrityError(\"Oops ...\") \n" 1066  "except dbapi.IntegrityError as inst: \n" 1067  " print(type(inst), inst)\n" 1074  " raise dbapi.InternalError(\"Oops ...\") \n" 1075  "except dbapi.InternalError as inst: \n" 1076  " print(type(inst), inst)\n" 1083  " raise dbapi.ProgrammingError(\"Oops ...\") \n" 1084  "except dbapi.ProgrammingError as inst: \n" 1085  " print(type(inst), inst)\n" 1092  " raise dbapi.NotSupportedError(\"Oops ...\") \n" 1093  "except dbapi.NotSupportedError as inst: \n" 1094  " print(type(inst), inst)\n" 1108  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

1113  sql

=

" CREATE TABLE #sale_stat ( \n" 1114  " year INT NOT NULL, \n" 1115  " month VARCHAR(255) NOT NULL, \n" 1116  " stat INT NOT NULL \n" 1123  ExecuteStr

(

"month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']"

);

1124  ExecuteStr

(

"umonth_list = [u'January', u'February', u'March', u'April', u'May', u'June', u'July', u'August', u'September', u'October', u'November', u'December']"

);

1125  ExecuteStr

(

"sql = \"insert into #sale_stat(year, month, stat) values (@year, @month, @stat)\""

);

1127  ExecuteStr

(

"print(\"Empty table contains %d records\" % len(cursor.fetchall()))"

);

1129  ExecuteStr

(

"cursor.executemany(sql, [{'@year':year, '@month':month, '@stat':stat} for stat in range(1, 3) for year in range(2004, 2006) for month in month_list])"

);

1131  ExecuteStr

(

"print(\"We have inserted %d records\" % len(cursor.fetchall()))"

);

1134  ExecuteStr

(

"print(\"After a 'standard' rollback command the table contains %d records\" % len(cursor.fetchall()))"

);

1138  ExecuteStr

(

"print(\"After a 'manual' rollback command the table contains %d records\" % len(cursor.fetchall()))"

);

1139  ExecuteStr

(

"cursor.executemany(sql, [{'@year':year, '@month':month, '@stat':stat} for stat in range(1, 3) for year in range(2004, 2006) for month in umonth_list])"

);

1141  ExecuteStr

(

"print(\"We have inserted %d records\" % len(cursor.fetchall()))"

);

1144  ExecuteStr

(

"print(\"After a 'manual' commit command the table contains %d records\" % len(cursor.fetchall()))"

);

1145  ExecuteSQL

(

"select month from #sale_stat"

);

1146  ExecuteStr

(

"month = cursor.fetchone()[0]"

);

1147  ExecuteStr

(

"if not isinstance(month, str) : " 1148  "raise Exception('Invalid data type: ') \n"

);

1149  ExecuteStr

(

"dbapi.return_strs_as_unicode(True)"

);

1150  ExecuteSQL

(

"select month from #sale_stat"

);

1151  ExecuteStr

(

"month = cursor.fetchone()[0]"

);

1152 #if PY_MAJOR_VERSION >= 3 1153  ExecuteStr

(

"if not isinstance(month, str): " 1154  "raise Exception('Invalid data type: ')\n"

);

1156  ExecuteStr

(

"if not isinstance(month, unicode) : " 1157  "raise Exception('Invalid data type: ') \n"

);

1159  ExecuteStr

(

"dbapi.return_strs_as_unicode(False)"

);

1160  ExecuteSQL

(

"select month from #sale_stat"

);

1161  ExecuteStr

(

"month = cursor.fetchone()[0]"

);

1162  ExecuteStr

(

"if not isinstance(month, str) : " 1163  "raise Exception('Invalid data type: ') \n"

);

1179  ExecuteStr

(

"from __future__ import with_statement \n" 1180  "with conn_simple.cursor() as cursor: \n" 1181  " for row in cursor.execute('exec sp_spaceused'): \n" 1183  " cursor.nextset() \n" 1184  " for row in cursor: \n" 1187  " cursor.execute('select * from sysobjects') \n" 1188  " raise Exception('DatabseError was not thrown') \n" 1189  "except dbapi.DatabaseError: \n" 1191  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

1192  ExecuteStr

(

"for row in cursor.execute('exec sp_spaceused'): \n" 1204  ExecuteStr

(

"cursor = conn_simple.cursor()\n"

);

1209  sql

=

" CREATE TABLE #sale_stat2 ( \n" 1210  " year INT NOT NULL, \n" 1211  " month VARCHAR(255) NOT NULL, \n" 1212  " stat INT NOT NULL \n" 1219  ExecuteStr

(

"month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']"

);

1220  ExecuteStr

(

"umonth_list = [u'January', u'February', u'March', u'April', u'May', u'June', u'July', u'August', u'September', u'October', u'November', u'December']"

);

1221  ExecuteStr

(

"sql = \"insert into #sale_stat2(year, month, stat) values (@year, @month, @stat)\""

);

1223  ExecuteStr

(

"print(\"Empty table contains %d records\" % len(cursor.fetchall()))"

);

1225  ExecuteStr

(

"cursor.executemany(sql, [[year, month, stat] for stat in range(1, 3) for year in range(2004, 2006) for month in month_list])"

);

1227  ExecuteStr

(

"print(\"We have inserted %d records\" % len(cursor.fetchall()))"

);

1230  ExecuteStr

(

"print(\"After a 'standard' rollback command the table contains %d records\" % len(cursor.fetchall()))"

);

1234  ExecuteStr

(

"print(\"After a 'manual' rollback command the table contains %d records\" % len(cursor.fetchall()))"

);

1235  ExecuteStr

(

"cursor.executemany(sql, [[year, month, stat] for stat in range(1, 3) for year in range(2004, 2006) for month in umonth_list])"

);

1237  ExecuteStr

(

"print(\"We have inserted %d records\" % len(cursor.fetchall()))"

);

1240  ExecuteStr

(

"print(\"After a 'manual' commit command the table contains %d records\" % len(cursor.fetchall()))"

);

1256  " cu = getCon().cursor() \n" 1257  " cu.execute(\"SELECT name from sysobjects " 1258  " WHERE name = 'customers' AND type = 'U'\") \n" 1259  " if len(cu.fetchall()) > 0: \n" 1260  " cu.execute(\"DROP TABLE customers\") \n" 1261  " cu.execute(\"\"\" \n" 1262  " CREATE TABLE customers ( \n" 1263  " cust_name VARCHAR(255) NOT NULL \n" 1266  " getCon().commit() \n" 1270  " cu = getCon().cursor() \n" 1271  " cu.execute(\"select * from customers\") \n" 1272  " print(cu.fetchall())\n" 1276  " cu = getCon().cursor() \n" 1277  " cu.execute(\"delete from customers\") \n" 1278  " getCon().commit() \n" 1282  " cu = getCon().cursor() \n" 1283  " sql = \"insert into customers(cust_name) values (@name)\" \n" 1284  " cu.execute(sql, {'@name':'1111'}) \n" 1285  " cu.execute(sql, {'@name':'2222'}) \n" 1286  " cu.execute(sql, {'@name':'3333'}) \n" 1287  " getCon().rollback() \n" 1288  " cu.execute(sql, {'@name':'Jane'}) \n" 1289  " cu.execute(sql, {'@name':'Doe'}) \n" 1290  " cu.execute(sql, {'@name':'Scott'}) \n" 1291  " getCon().commit() \n" 1296  " conn = dbapi.connect('ftds', 'MSSQL', 'MSDEV1', 'DBAPI_Sample', 'DBAPI_test', 'allowed', True) \n" 1297  " CreateSchema() \n" 1298  " CreateCustomers() \n" 1299  " GetCustomers() \n" 1300  " DeleteCustomers() \n"

static CNcbiApplication * Instance(void)

Singleton method.

void SetDatabaseParameters(void)

TDatabaseParameters m_DatabaseParameters

string GetServerTypeStr(void) const

string GetServerName(void) const

string GetDriverName(void) const

EServerType GetServerType(void) const

static void ResetEnvSybase(void)

static void ExecuteStr(const char *cmd)

static void ExecuteFile(const char *file_name)

static char long_string[512]

CNcbiEnvironment & SetEnvironment(void)

Get a non-const copy of the application's cached environment.

virtual const CArgs & GetArgs(void) const

Get parsed command line arguments.

@ eString

An arbitrary string.

void DereferenceLink(ENormalizePath normalize=eNormalizePath)

Dereference a link.

const string & GetPath(void) const

Get entry path.

static void EnableGlobally(bool enable=true)

Enable (or disable, if called with enable = false) loading plugins from DLLs in general.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)

Convert string to double.

static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)

Check if a string starts with a specified prefix value.

Defines the CNcbiApplication and CAppException classes for creating NCBI applications.

Defines command line argument related classes.

Defines unified interface to application:

Plugin manager (using class factory paradigm).

static const CTestArguments & GetArgs(void)

static void ExecuteStr(const char *cmd)

BOOST_AUTO_TEST_CASE(TestBasic)

NCBITEST_INIT_CMDLINE(arg_desc)

static void ExecuteSQL(const string &sql)

NCBITEST_INIT_VARIABLES(parser)

static pythonpp::CEngine * s_Engine

static string GetSybaseClientVersion(void)

Utility stuff for more convenient using of Boost.Test library.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4