<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: symbian code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 10:07:41 GMT</pubDate>
    <description>DZone Snippets: symbian code</description>
    <item>
      <title>Create a primary key with autoincrement in Symbian DBMS</title>
      <link>http://snippets.dzone.com/posts/show/1680</link>
      <description>&lt;code&gt;&lt;br /&gt;CREATE TABLE person (id COUNTER, name VARCHAR)&lt;br /&gt;CREATE UNIQUE INDEX id_index ON person(id)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;COUNTER is UNSIGNED INTEGER with Autoincrement.&lt;br /&gt;You still need a UNIQUE INDEX as well.</description>
      <pubDate>Fri, 10 Mar 2006 16:17:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1680</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Interactive SQL shell</title>
      <link>http://snippets.dzone.com/posts/show/1669</link>
      <description>To help myself learning about SQL in Symbain DBMS, I write&lt;br /&gt;a small script to act as an interactive SQL shell.&lt;br /&gt;First you need to connect to the database.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; import e32db&lt;br /&gt;&gt;&gt;&gt; db = e32db.Dbms()&lt;br /&gt;&gt;&gt;&gt; dbv = e32db.Db_view()&lt;br /&gt;&gt;&gt;&gt; db.open(u'C:\\test.db')  # might need db.create(...)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Here's the query simplification code.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def Q(sql):&lt;br /&gt;    if sql.upper().startswith('SELECT'):&lt;br /&gt;        dbv.prepare(db, unicode(sql))&lt;br /&gt;        dbv.first_line()&lt;br /&gt;        rows = []&lt;br /&gt;        maxlen = [0] * dbv.col_count()&lt;br /&gt;        for i in range(dbv.count_line()):&lt;br /&gt;            dbv.get_line()&lt;br /&gt;            result = []&lt;br /&gt;            for i in range(dbv.col_count()):&lt;br /&gt;                try:&lt;br /&gt;                    val = dbv.col(i+1)&lt;br /&gt;                except:    # in case coltype 16&lt;br /&gt;                    val = None&lt;br /&gt;                result.append(val)&lt;br /&gt;                maxlen[i] = max(maxlen[i], len(str(val)))&lt;br /&gt;            rows.append(result)&lt;br /&gt;            dbv.next_line()&lt;br /&gt;        fmt = '|'+ '|'.join(['%%%ds' % n for n in maxlen]) + '|'&lt;br /&gt;        for row in rows:&lt;br /&gt;            print fmt % tuple(row) &lt;br /&gt;    else:&lt;br /&gt;        n = db.execute(unicode(sql))&lt;br /&gt;        print '%d rows affected' % n&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;After that, playing with SQL is quite simple.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; Q("CREATE TABLE person (id COUNTER, name VARCHAR)")&lt;br /&gt;0 rows affected&lt;br /&gt;&gt;&gt;&gt; Q("INSERT INTO person(name) VALUES ('Korakot')")&lt;br /&gt;1 rows affected&lt;br /&gt;&gt;&gt;&gt; Q("INSERT INTO person(name) VALUES ('morning_glory')")&lt;br /&gt;1 rows affected&lt;br /&gt;&gt;&gt;&gt; Q("SELECT * from person")&lt;br /&gt;|0|      Korakot|&lt;br /&gt;|1|morning_glory|&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 09 Mar 2006 14:01:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1669</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>SQL for Symbian DBMS</title>
      <link>http://snippets.dzone.com/posts/show/1668</link>
      <description>I have summarized the allowable SQL below.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# 'SELECT' is the most popular SQL&lt;br /&gt;SELECT select-list FROM table-name [ WHERE search-condition ] [ ORDER BY sort-order ] &lt;br /&gt;# 3 search condition types: compare, like, null&lt;br /&gt;&lt;br /&gt;# DML : INSERT, DELETE, UPDATE &lt;br /&gt;INSERT INTO table-name [ ( column-identifier,&#8230; ) ] VALUES ( column-value,&#8230; ) &lt;br /&gt;DELETE FROM table-name [ WHERE search-condition ] &lt;br /&gt;UPDATE table-name SET update-column,&#8230; [ WHERE search-condition ] &lt;br /&gt;&lt;br /&gt;# DDL : Work with the schema&lt;br /&gt;CREATE TABLE table-name (column-definition,&#8230;) &lt;br /&gt;DROP TABLE table-name &lt;br /&gt;ALTER TABLE table-name { ADD add-column-set [ DROP drop-column-set ] | DROP drop-column-set } &lt;br /&gt;CREATE [ UNIQUE ] INDEX index-name ON table-name ( sort-specification,&#8230; ) &lt;br /&gt;DROP INDEX index-name FROM table-name &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Plus a few column types (not all of them)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;['BIT', 'INTEGER', 'COUNTER', 'BIGINT', 'FLOAT',&lt;br /&gt; 'TIMESTAMP', 'VARCHAR(n)', 'LONG VARCHAR']&lt;br /&gt;# COUNTER is an auto-incremented unsigned integer&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 13:04:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1668</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Symbian phone list</title>
      <link>http://snippets.dzone.com/posts/show/1630</link>
      <description>&lt;code&gt;&lt;br /&gt;# S60 3rd Edition (Symbian OS v9.1)&lt;br /&gt;Nokia E60, E61, E70&lt;br /&gt;Nokia 3250&lt;br /&gt;Nokia N71, N80, N91, N92&lt;br /&gt;&lt;br /&gt;# S60 2nd Edition FP3 (Symbian OS v8.1)&lt;br /&gt;Nokia N70, N90&lt;br /&gt;&lt;br /&gt;# S60 2nd Edition FP2 (Symbian OS v8.0a)&lt;br /&gt;Nokia 6630, 6680, 6681, 6682&lt;br /&gt;Lenovo P930&lt;br /&gt;&lt;br /&gt;# S60 2nd Edition FP1 (Symbian OS v7.0s enhanced)&lt;br /&gt;Nokia 3230, 6260, 6620, 6670, 7610&lt;br /&gt;Panasonic X700, X800&lt;br /&gt;Samsung SDH-D720&lt;br /&gt;&lt;br /&gt;# S60 2nd Edition (Symbian OS v7.0s)&lt;br /&gt;Nokia 6600&lt;br /&gt;&lt;br /&gt;# S60 1st Edition (Symbian OS v6.1)&lt;br /&gt;Nokia 3600, 3620, 3650, 3660, 7650&lt;br /&gt;Nokia N-Gage, N-Gage QD&lt;br /&gt;Sendo X&lt;br /&gt;Siemens SX1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;See &lt;a href=http://www.symbian.com/developer/sdks_series60.asp&gt;official list&lt;/a&gt;.</description>
      <pubDate>Sat, 04 Mar 2006 06:22:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1630</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Finding all symbian database files</title>
      <link>http://snippets.dzone.com/posts/show/1465</link>
      <description>Hmm.. I am considering hacking the Dbms format.&lt;br /&gt;I want to know what tables are there in each db file.&lt;br /&gt;The first step is to list all such files.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; def print_db(arg, dirname, names):&lt;br /&gt;...   for name in names:&lt;br /&gt;...     if name.endswith('.db'):&lt;br /&gt;...       print dirname + '\\' + name&lt;br /&gt;...&lt;br /&gt;&gt;&gt;&gt; os.path.walk('C:\\', print_db, None)&lt;br /&gt;C:\\SportsDiary.db&lt;br /&gt;C:\\test.db&lt;br /&gt;C:\system\Data\Bookmarks1.db&lt;br /&gt;C:\system\Data\lcscfg.db&lt;br /&gt;C:\system\Data\lcs.db&lt;br /&gt;C:\system\Data\NSmlDSSettings.db&lt;br /&gt;C:\system\Data\SavedDecks1.db&lt;br /&gt;C:\system\Data\midp2\systemams\MIDP2SystemAMSDynamic.db&lt;br /&gt;C:\system\Data\midp2\systemams\MIDP2SystemAMSStatic.db&lt;br /&gt;C:\system\Data\srsplugin\SDDatabase.db&lt;br /&gt;C:\system\Data\vasdb\vasdatabase.db&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 12 Feb 2006 20:16:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1465</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
