From: Patrick D. <pat...@ac...> - 2009-02-10 13:53:45
|
Hi, I have read tip 308 and various other web pages but can't seem to find any comprehensive documentation on the use of TDBC and the small bits of example code that I have found seem to be conflicting. I can help with the testing effort but need some information on how to use TDBC in my scripts. Thanks Patrick Dunnigan Email: pat...@ac... Visit us at <file:///C:\Documents%20and%20Settings\pdunnigan\Application%20Data\Microsof t\Signatures\www.activecompliance.com> www.activecompliance.com This e-mail message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is confidential. If you are not the intended recipient, any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by reply email. |
From: Larry W. V. <lv...@gm...> - 2009-02-10 14:20:31
|
On Tue, Feb 10, 2009 at 8:26 AM, Patrick Dunnigan <pat...@ac...> wrote: > Hi, I have read tip 308 and various other web pages but can't seem to find > any comprehensive documentation on the use of TDBC and the small bits of > example code that I have found seem to be conflicting. I can help with the > testing effort but need some information on how to use TDBC in my scripts. > I know I went out to http://tdbc.tcl.tk/ this morning, and found a minimal amount of info on the wiki. However, I noticed that when I built Tcl 8.6 cvs head (obtained from the activestate ftp site) there were 5 man pages tdbc.n, tdbc_connection.n, tdbc_statement.n, tdbc_resultset.n, tdbc_tokenize.n that are installed when I configured, built, and then installed the code in tcl/pkgs/tdbc/ . I also note that there doesn't appear to be any drivers that are in the tcl 8.6 source distribution right now. When I poke around on the tdbc.tcl.tk site, I see a set of hyperlinks to code. However, I'm uncertain exactly how one gets the code . Also, is anyone working on oracle or sybase drivers for tdbc yet? Just curious. -- Tcl - The glue of a new generation. http://wiki.tcl.tk/ Larry W. Virden http://www.purl.org/net/lvirden/ http://www.xanga.com/lvirden/ Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions. |
From: Kevin K. <kk...@ny...> - 2009-02-10 15:40:48
|
Larry W. Virden wrote: > I know I went out to http://tdbc.tcl.tk/ this morning, and found a > minimal amount of info on the wiki. However, I noticed that when I > built Tcl 8.6 cvs head (obtained from the activestate ftp site) there > were 5 man pages tdbc.n, tdbc_connection.n, tdbc_statement.n, > tdbc_resultset.n, tdbc_tokenize.n that are installed when I > configured, built, and then installed the code in tcl/pkgs/tdbc/ . > > I also note that there doesn't appear to be any drivers that are in > the tcl 8.6 source distribution right now. When I poke around on the > tdbc.tcl.tk site, I see a set of hyperlinks to code. However, I'm > uncertain exactly how one gets the code . Windows drivers are at http://preview.tinyurl.com/db2zw8 . Unix users can build from the ZIP files, downloadable by following the "If you're here to get the sources" instructions on the tdbc.tcl.tk front page. It's all still beta, of course. > > Also, is anyone working on oracle or sybase drivers for tdbc yet? > Just curious. I don't know of any. I'm not the right one to do Sybase, since I don't have access to a Sybase system and haven't used it in years. It's certainly needed. (Is "SQL Server Native API" still enough like Sybase that a common code base could be used for both?) A stopgap would be to use the ODBC bridge. A slightly better stopgap would be to do a pure Tcl driver wrapped around sybtcl, much as the SQLite3 driver is wrapped around SQLite3's native binding. Someone at the conference raised a hand when I asked if anyone was planning an Oracle driver, and then I heard nothing further. Really, people, I can't do it all myself! -- 73 de ke9tv/2, Kevin |
From: Kevin K. <kk...@ny...> - 2009-02-10 15:40:45
|
Patrick Dunnigan wrote: > Hi, I have read tip 308 and various other web pages but can’t seem to > find any comprehensive documentation on the use of TDBC and the small > bits of example code that I have found seem to be conflicting. I can > help with the testing effort but need some information on how to use > TDBC in my scripts. Unfortunately, there isn't very much tutorial information out there. The manual pages *are* there, and if you install drivers (which you have to do to actually *use* tdbc) their manual pages will be there, too. 308 didn't change very much between TIP and implementation, but I agree that TIP prose isn't the easiest thing in the world to read. How far have you got? I don't think that an email thread is the best place to start developing a tutorial, but perhaps we can Wikify the missing knowledge and whack it into a decent form. That will be easiest to do starting from specific questions. In any case, if you haven't already, you need to: (a) Either have 8.6b1 (or later), or else have 8.5 plus the tcloo extension and the tdbc extension. (b) Have a SQL database that you can use. Windows users always have Jet (the engine underlying Microsoft Access) available, even if they haven't bought Access. SQLite runs everywhere. And TDBC has a MySQL driver. (c) Have the driver for the database. Windows users can get binaries for the drivers that are so far available (ODBC, MySQL and SQLite3) from http://preview.tinyurl.com/db2zw8 Unix users at this point still have to build from source. Source ZIPs are available from http://tdbc.tcl.tk/ (d) Once you have a driver built and operational, or if you get stuck, start asking questions! There isn't that much there, but I've probably neglected to document some key piece that's making you stumble. A summary example will give the basic idea: tdbc::sqlite3::connection create db /path/to/my/database.sql db allrows { CREATE TABLE people( name VARCHAR(40), phone VARCHAR(16) ) } set stmt [db prepare { INSERT INTO people(name, phone) VALUES(:name, :phone) }] foreach {name phone} { fred 555-1234 barney 555-1235 wilma 555-1234 betty 555-1235 } { $stmt allrows } $db foreach row {SELECT phone FROM people where NAME='fred'} { if {[dict exists $row phone]} { puts $phone } else { puts "fred has no phone" } } $db close |
From: Patrick D. <pat...@ac...> - 2009-02-10 15:24:18
|
Here's the background: I have an enterprise-grade software solution that has been in production use for 6+ years, the most important component of which is written in TCL / Expect. We've been using various methods to connect to databases over the years, from ODBC bridges to TCLtoDBI Perl to our own connectivity library to connect to SQL Server / Sybase (through freeTDS), Oracle OCI, SQLite, MySQL etc. Kind of a home grown ODBC without needing Unix ODBC. Works very well and is very fast. Well we need to port to Windows and I would like to explore the possibility of not using the home grown connectivity library. I can use TclODBC for the SQL Server piece but it doesn't look like it's in active development and I'd like to make sure we stay with something active. TDBC is now popping up so I'd like to see if it fits the needs. I downloaded ActiveState 8.6b1. Tested TclODBC connectivity to SQL Server 2005 Enterprise, works fine. I then moved onto tdbc, tried passing in a connection string with no success. I then realized that I didn't have enough information on the command syntax. I looked for man pages, etc. etc. and didn't locate them. I then downloaded the zip file referenced by the link below, ran the install and had errors at every step, couldn't create directories, etc. I edited the install script and removed the -force on the file mkdir commands, still had errors so I decided to go for help. The line I decided to stop on was: file mkdir [file join $::tcl_library tcl8/8.6/tdbc]. I didn't have confidence that this was the proper path. The path it would create in my case would be: C:\Tcl\lib\tcl8.6\tcl8\8.6\tdbc Therefore, my questions would be: 1. is this the most recent and accurate install script? 2. How would I pass a SQL Server ODBC connection string to the tdbc connection command? 3. You mentioned man pages are there, but I don't see them in the Active State 8.6b1 install or on the web. Can you point me to them? Thanks for your response. Patrick Dunnigan Email: pat...@ac... Visit us at www.activecompliance.com This e-mail message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is confidential. If you are not the intended recipient, any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by reply email. -----Original Message----- From: Kevin Kenny [mailto:kk...@ny...] Sent: Tuesday, February 10, 2009 9:53 AM To: pat...@ac... Cc: tcl...@li... Subject: Re: [Tcl-tdbc] TDBC documentation, samples Patrick Dunnigan wrote: > Hi, I have read tip 308 and various other web pages but can't seem to > find any comprehensive documentation on the use of TDBC and the small > bits of example code that I have found seem to be conflicting. I can > help with the testing effort but need some information on how to use > TDBC in my scripts. Unfortunately, there isn't very much tutorial information out there. The manual pages *are* there, and if you install drivers (which you have to do to actually *use* tdbc) their manual pages will be there, too. 308 didn't change very much between TIP and implementation, but I agree that TIP prose isn't the easiest thing in the world to read. How far have you got? I don't think that an email thread is the best place to start developing a tutorial, but perhaps we can Wikify the missing knowledge and whack it into a decent form. That will be easiest to do starting from specific questions. In any case, if you haven't already, you need to: (a) Either have 8.6b1 (or later), or else have 8.5 plus the tcloo extension and the tdbc extension. (b) Have a SQL database that you can use. Windows users always have Jet (the engine underlying Microsoft Access) available, even if they haven't bought Access. SQLite runs everywhere. And TDBC has a MySQL driver. (c) Have the driver for the database. Windows users can get binaries for the drivers that are so far available (ODBC, MySQL and SQLite3) from http://preview.tinyurl.com/db2zw8 Unix users at this point still have to build from source. Source ZIPs are available from http://tdbc.tcl.tk/ (d) Once you have a driver built and operational, or if you get stuck, start asking questions! There isn't that much there, but I've probably neglected to document some key piece that's making you stumble. A summary example will give the basic idea: tdbc::sqlite3::connection create db /path/to/my/database.sql db allrows { CREATE TABLE people( name VARCHAR(40), phone VARCHAR(16) ) } set stmt [db prepare { INSERT INTO people(name, phone) VALUES(:name, :phone) }] foreach {name phone} { fred 555-1234 barney 555-1235 wilma 555-1234 betty 555-1235 } { $stmt allrows } $db foreach row {SELECT phone FROM people where NAME='fred'} { if {[dict exists $row phone]} { puts $phone } else { puts "fred has no phone" } } $db close |
From: Kevin K. <kk...@ny...> - 2009-02-11 01:24:59
|
Patrick Dunnigan wrote: > Here's the background: > > I have an enterprise-grade software solution that has been in production use > for 6+ years, the most important component of which is written in TCL / > Expect. > > We've been using various methods to connect to databases over the years, > from ODBC bridges to TCLtoDBI Perl to our own connectivity library to > connect to SQL Server / Sybase (through freeTDS), Oracle OCI, SQLite, MySQL > etc. Kind of a home grown ODBC without needing Unix ODBC. Works very well > and is very fast. > > Well we need to port to Windows and I would like to explore the possibility > of not using the home grown connectivity library. I can use TclODBC for the > SQL Server piece but it doesn't look like it's in active development and I'd > like to make sure we stay with something active. TDBC is now popping up so > I'd like to see if it fits the needs. Exciting. I want to help. > I downloaded ActiveState 8.6b1. Tested TclODBC connectivity to SQL Server > 2005 Enterprise, works fine. Half the battle. If ODBC is going, tdbc::odbc will work fine. > I then moved onto tdbc, tried passing in a connection string with no > success. I then realized that I didn't have enough information on the > command syntax. I looked for man pages, etc. etc. and didn't locate them. Yes, I see that the Webification of the man pages is not happening, and I'm not sure why, but I'll track it down. > I then downloaded the zip file referenced by the link below, ran the install > and had errors at every step, couldn't create directories, etc. I edited the > install script and removed the -force on the file mkdir commands, still had > errors so I decided to go for help. > > The line I decided to stop on was: file mkdir [file join $::tcl_library > tcl8/8.6/tdbc]. I didn't have confidence that this was the proper path. > The path it would create in my case would be: > > C:\Tcl\lib\tcl8.6\tcl8\8.6\tdbc Ouch, that's not right; looks as if I've got a regression in the installer. Let me check it out and get back to you. > 1. is this the most recent and accurate install script? Recent, yes. Accurate, obviously not. Let me get it fixed and get back to you. > 2. How would I pass a SQL Server ODBC connection string to the tdbc > connection command? tdbc::odbc::connection create db $connectionString and 'db' becomes a TDBC connection handle. Replace 'db' with whatever command name you'd like it to have. > 3. You mentioned man pages are there, but I don't see them in the Active > State 8.6b1 install or on the web. Can you point me to them? I don't see them on www.tcl.tk, either - let me get with Jeff and Andreas and see if they can track down the reason they're not showing up. I'll put HTML ones up for you and post back here again. -- 73 de ke9tv/2, Kevin |
From: Kevin K. <kk...@ny...> - 2009-02-11 03:04:08
|
Patrick Dunnigan wrote: > 3. You mentioned man pages are there, but I don't see them in the Active > State 8.6b1 install or on the web. Can you point me to them? I still need to troubleshoot what's gone wrong with having the TDBC documents in ActiveTcl and on the www.tcl.tk web site, but I've bundled up the manual pages in HTML format over at http://preview.tinyurl.com/be7uj3 - download and unpack 'tdbc1.0b7-doc.ZIP' Onward to figuring out what's gone awry with the Windows binary installer - I'd have sworn I'd fixed that bug! -- 73 de ke9tv/2, Kevin |