bmartin wrote:Tomas's External has been replaced by Alec's External, of the same name I believe. It is made for the newer versions of SC and does not require Bundle Bridge to work. I use Alec's external in a production application I wrote for work, and so far it has not let me down.
Curt wrote:However, I have found this to be very frustrating. I have no previous experience with these databases, and I'm finding it difficult to code the connections properly using SuperCard and the external written by Thomas Franzén.
My first question is whether his SQLite external really works for entering data into a new database. The program that I downloaded from the Internet seems to work fine on queries but it gives scant advice on how to code/script the SuperCard interface to enter data into a database. He seems to presuppose a lot of knowledge and experience. Mostly I need reassurance that it does work and that there is some place for me to see examples and learn how to work it.
function dbQuery query, tItemDel, tLineDel
put dbOpen(dbFile()) into dbID
if tLineDel is "" then put "cr" into tLineDel
if tItemDel is "" then put "|" into tItemDel
get SQLite_Query (dbID, tLineDel, tItemDel, query)
dbClose dbID
return it
end dbQuery
function dbFile
-- hard wired database name
return "wkc.db"
end dbFile
function dbOpen dbPath
get SQLite_Open(dbPath)
return it
end dbOpen
function SQLite_Open dbPath
-- This is a modified version of the SQLite_Open function from the sample project
global gLP_defaultSQLiteFolder
-- gLP_defaultSQLiteFolder is a global that contains a default folder for my db files
-- so I can make calls without dealing with the path... Just the db name
if not (dbPath contains ":") then
-- It's only a name, not a whole path provided in dbPath
put gLP_defaultSQLiteFolder & ":" & dbPath into dbPath
end if
get SQLite("open",dbPath)
return it
end SQLite_Open
on dbClose dbID
get SQLite_Close (dbID)
end dbClose
put "CREATE TABLE Persons (P_Id int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255));" into dbQuery
get dbQuery(tQuery)
-- no reply necessary
put "INSERT INTO Persons VALUES (4,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger');" into dbQuery
get dbQuery(tQuery)
-- no reply necessary
put "SELECT * FROM persons WHERE LastName like 'Nilsen';" into dbQuery
get dbQuery(tQuery)
function dbTables
put dbOpen(dbFile()) into dbID
put SQLite_Tables (dbID) into tTables
dbClose dbID
return tTables
end dbTables
function dbColumns tableName
put dbOpen(dbFile()) into dbID
put SQLite_Columns (dbID, tableName) into tColumns
dbClose dbID
return tColumns
end dbTables
function dbColumns dbID, tableName
return SQLite_Columns (dbID, tableName)
end dbColumns
Josh wrote:This sqlite3 is intriguing. It only works with OSX right?
IOW, it wouldn't work on a G3 running OS9.2. but will work
on a G4 running OS 10.4.11 and SC4.5.2 I assume.
-- Josh
lthompson wrote:Thanks, guys, for the sample projects and all the useful info. I have an old (SC3) project that needs rebuilding from the ground up and was wondering if a sql db would work for storing the data. Does anyone know if there's a limit to how much text you can have in an entry? Some of my entries might be 500 characters or more. Would sqlite be feasible? Thanks.
------------ My altered wrappers in a window script: -----------
function SQLite_OpenFKIJobberDatabase
global gSQLconnectID
if gSQLconnectID = empty then -- No database previously opened this session,
-- -- Proceed to open/create it at project-folder level
put projpath(this proj) & "FKIJobberDatabase" into databasePath
get SQLite("open",databasePath)
if isNumber(it) then
put it into gSQLconnectID
return it
else
beep
answer "Unknown database problem." with "Exit"
exit to supercard
end if
else
beep
answer "Database already open = # " & gSQLconnectID
return gSQLconnectID
end if
end SQLite_OpenFKIJobberDatabase
function SQLite_CloseFKIJobberDatabase
global gSQLconnectID
if gSQLconnectID = empty then -- no database previously opened this session, exit now
beep
answer "No FKIJobberDatabase open." with "Exit"
exit to supercard
else
get SQLite("close",gSQLconnectID)
put empty into gSQLconnectID
return it
end if
end SQLite_CloseFKIJobberDatabase
---------------- From my test popup menu ----------------
on itemSelect -- for Open
get SQLite_OpenFKIJobberDatabase() -- from my own wrappers in WD
put it -- debug
end itemSelect
on itemSelect -- for Close
get SQLite_CloseFKIJobberDatabase()
put it -- debug
end itemSelect
on SQLiteOpen
global sqlCurrentSession,databasePath
if sqlCurrentSession=empty then
put SQLite("open",databasePath) into sqlCurrentSession
sqlMsg "Open" && sqlCurrentSession
else
sqlMsg "SQL connection already open"
end if
end SQLiteOpen
on SQLiteClose
global sqlCurrentSession,sqlTransactionActive
if sqlTransactionActive = true then
SQLiteEndTransaction
end if
if sqlCurrentSession<>empty then
sqlMsg "close" && sqlCurrentSession
get SQLite("close",sqlCurrentSession)
put empty into sqlCurrentSession
end if
end SQLiteClose
on SQLiteBeginTransaction
global sqlCurrentSession,sqlTransactionActive
if sqlCurrentSession<>empty and sqlTransactionActive=false then
sqlMsg "begin transaction" && sqlCurrentSession
get SQLite("begin",sqlCurrentSession)
put true into sqlTransactionActive
end if
end SQLiteBeginTransaction
on SQLiteEndTransaction
global sqlCurrentSession,sqlTransactionActive
if sqlCurrentSession<>empty and sqlTransactionActive=true then
sqlMsg "end transaction" && sqlCurrentSession
get SQLite("end",sqlCurrentSession)
put false into sqlTransactionActive
end if
end SQLiteEndTransaction
on sqlMsg tMsg
if tMsg is not empty then
put tMsg into message box
end if
end sqlMsg
put replace(tText,quote,quote & quote) into tText
put replace(tText,null,"") into tText
Users browsing this forum: No registered users and 1 guest