Sqlite syntax

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • firephreek

    Sqlite syntax

    Is there some documentation out there that actually lists the Sqlite
    syntax?
    Or even better, one that crosses over and talks about how it works with
    python?

    Sqlite seems quite the nifty little thing, but for some reason, I can't
    seem to get a list of tables in my databases through a python prompt.

    Help?

    And since the databases aren't 'centralized' there's no way of knowing
    what databases I have floating around is there?

    Stryder


  • David M. Cooke

    #2
    Re: Sqlite syntax

    At some point, "firephreek " <firephreek@ear thlink.net> wrote:
    [color=blue]
    > Is there some documentation out there that actually lists the Sqlite
    > syntax?[/color]

    You mean the SQL dialect it speaks? http://sqlite.org/lang.html
    [color=blue]
    > Or even better, one that crosses over and talks about how it works with
    > python?[/color]

    Like all the other DB interfaces. See the pysqlite homepage for specifics.
    [color=blue]
    > Sqlite seems quite the nifty little thing, but for some reason, I can't
    > seem to get a list of tables in my databases through a python
    > prompt.[/color]

    From http://sqlite.org/lang.html#createtable, all the tables are
    listed in the sqlite_master table, so
    [color=blue][color=green][color=darkred]
    >>> import sqlite
    >>> cx = sqlite.connect( "db")
    >>> cu = cx.cursor()
    >>> cu.execute('''S ELECT * FROM sqlite_master'' ')[/color][/color][/color]
    [('table', 'TEST', 'TEST', 3, 'CREATE TABLE TEST (V VARCHAR, I INTEGER)')]
    [color=blue]
    > And since the databases aren't 'centralized' there's no way of knowing
    > what databases I have floating around is there?[/color]

    Use 'ls' :-). Each database is a separate file.

    --
    |>|\/|<
    /--------------------------------------------------------------------------\
    |David M. Cooke
    |cookedm(at)phy sics(dot)mcmast er(dot)ca

    Comment

    • Frithiof Andreas Jensen

      #3
      Re: Sqlite syntax


      "firephreek " <firephreek@ear thlink.net> wrote in message
      news:mailman.17 .1084816067.694 9.python-list@python.org ...
      [color=blue]
      > Is there some documentation out there that actually lists the Sqlite
      > syntax?[/color]


      [color=blue]
      > Or even better, one that crosses over and talks about how it works with
      > python?[/color]

      That be mainly here: http://www.python.org/topics/database/ under
      This API has been defined to encourage similarity between the Python modules that are used to access databases. By doing this, we hope to achieve a consistency leading to more easily understood modules, code that is generally more portable across datab...

      [color=blue]
      > And since the databases aren't 'centralized' there's no way of knowing
      > what databases I have floating around is there?[/color]

      It is "lite" - which means that you have to remember where you put stuff ;-)
      A ConfigParser object is a good place to keep track of that sort of thing.


      Comment

      • Dominique Orban

        #4
        Re: Sqlite syntax

        On 2004-05-28, Frithiof Andreas Jensen <frithiof.jense n@die_spammer_d ie.ericsson.com > wrote:[color=blue]
        >
        > "firephreek " <firephreek@ear thlink.net> wrote in message
        > news:mailman.17 .1084816067.694 9.python-list@python.org ...
        >[color=green]
        >> Is there some documentation out there that actually lists the Sqlite
        >> syntax?[/color]
        >
        > http://sqlite.org/lang.html
        >[color=green]
        >> Or even better, one that crosses over and talks about how it works with
        >> python?[/color]
        >
        > That be mainly here: http://www.python.org/topics/database/ under
        > http://www.python.org/peps/pep-0249.html[/color]

        See also http://pysqlite.sf.net
        Their website in a bit on the brief side as the documentation is being
        updated, but check out the mailing list for examples on how to use it.
        It is a most convenient and powerful interface with intuitive commands.
        You ought to check it out!
        [color=blue][color=green]
        >> And since the databases aren't 'centralized' there's no way of knowing
        >> what databases I have floating around is there?[/color]
        >
        > It is "lite" - which means that you have to remember where you put stuff ;-)
        > A ConfigParser object is a good place to keep track of that sort of thing.
        >
        >[/color]

        Comment

        Working...