#!python
# sqlite3_test, a test of python and sqlite

import sqlite3

connection = sqlite3.connect(':memory:')

# create a table
connection.execute('create table events(ts, msg)')

# insert values
connection.executemany('insert into events values(?,?)',
    [(1, 'foo'), (2,'bar'), (3,'baz') ] )

# print inserted rows
for row in connection.execute('select * from events'):
    print(row)

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of John R. Sowden
>Sent: Sunday, 22 October, 2017 22:24
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] very sqlite3 noobie error
>
>thank you.  i think there are too many errors in this guide for me to
>use it.
>
>John
>
>
>On 10/22/2017 09:03 PM, Keith Medcalf wrote:
>> There are a number of syntax errors.
>>
>> Line 1 - You have an / that should not be there.
>> Line 6 - You cannot call a module, only a function in a module (not
>strictly true, but in the case of pysqlite2, it is)
>> Line 12 - You are missing the closing quote on the SQL string
>> Line 17 - You have not indented the line
>>
>> As for your syntax error, you probably have crap on a line that you
>think is empty.  Or your editor is not putting in line endings
>properly and you have all one long continuation line.  The syntax
>error was detected at the opening bracket on line 6 but your actual
>error occurred long before this.
>>
>> You may need to use a better text editor, or one that you are more
>familiar with.
>>
>> ---
>> The fact that there's a Highway to Hell but only a Stairway to
>Heaven says a lot about anticipated traffic volume.
>>
>>> -----Original Message-----
>>> From: sqlite-users [mailto:sqlite-users-
>>> boun...@mailinglists.sqlite.org] On Behalf Of John R. Sowden
>>> Sent: Sunday, 22 October, 2017 20:59
>>> To: sqlite-users@mailinglists.sqlite.org
>>> Subject: [sqlite] very sqlite3 noobie error
>>>
>>> Since I am trying to learn sqlite3 (unlearning foxpro) I find that
>>> python is the simpleist language, wfich allows me to focus on
>sqlite,
>>> I
>>> amtrying the =guide just sent to the list.
>>>
>>> I am getting a syntax error on line 5.  below is the program
>copied
>>> by
>>> hand from the guide:
>>>
>>> ----------------------
>>> #/!python
>>> # sqlite3_test, a test of python and sqlite
>>>
>>> import sqlite3
>>>
>>> connection = sqlite3(':memory:')
>>>
>>> # create a table
>>> connection.execute('create table events(ts, msg)')
>>>
>>> # insert values
>>> connection.execute('insert into events values(?,?),
>>>     [(1, 'foo'), (2,'bar'), (3,'baz') ] )
>>>
>>> # print inserted rows
>>> for row in connection.execute('select * from events'):
>>> print(row)
>>> -----------------------
>>>
>>> can anyone tell me where i am missing something?
>>>
>>> John
>>>
>>> _______________________________________________
>>> sqlite-users mailing list
>>> sqlite-users@mailinglists.sqlite.org
>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to