The mSQL module is very similar to the MySQL one. The entry point into the module is via the mSQL.connect() method. The return value from this method represents a connection to an mSQL database that you can use for all of your mSQL operations.
Method: mSQL.connect( ) |
connection = mSQL.connect() connection = mSQL.connect(host)
Connects to the mSQL database engine on the specified server. If you call connect with no arguments, the method connects to the database engine on the local machine. It returns an mSQL connection handle that you can use for database access.
connection = mSQL.connect(`carthage.imaginary.com')
Method: connection.selectdb( ) |
connection.selectdb(database)
Selects the name of the database for your connection to use. Any further operations on that connection will work against that database unless you later select a new database.
connection.selectdb(`test');
Method: connection.query( ) |
results = connection.query(sql)
Sends the specified SQL statement to the currently selected database for execution. The results are returned as a list of tuples, where each tuple represents a row. This method is also used for updates -- you just do not process the return value.
results = conn.query(`SELECT title, year FROM movies'); row1 = results[0];
Method: connection.listdbs( ) |
dbs = connection.listdbs()
Provides a Python list of databases available on the server.
dbs = conn.listdbs()
Method: connection.listtables( ) |
connection.listtables()
Provides a Python list of tables stored in the selected database.
tables = conn.listtables()
Attribute: connection.serverinfo |
Returns the version number of the mSQL instance to which you are currently connected.
info = connection.serverinfo;
Attribute: connection.hostname |
Returns the name of the server on which the mSQL instance is running.
host = connection.hostname
Copyright © 2001 O'Reilly & Associates. All rights reserved.
This HTML Help has been published using the chm2web software. |