very sqlite3 noobie error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

very sqlite3 noobie error

John R. Sowden
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
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Igor Korot
Hi, John,

On Sun, Oct 22, 2017 at 9:59 PM, John R. Sowden
<[hidden email]> wrote:
> 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:

What is the exact error message you received?
Please copy and paste it here in reply?

Also, what python version do you have?

Thank you.

>
> ----------------------
> #/!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
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

John R. Sowden
error from terminal program:
./sqlite3_test.py: line 6: syntax error near unexpected token `('
./sqlite3_test.py: line 6: `connection = sqlite3(':memory:')'
john@sentry35:~$

version 2.7.12 (ubuntu 16,04 lts)

John




On 10/22/2017 08:07 PM, Igor Korot wrote:

> Hi, John,
>
> On Sun, Oct 22, 2017 at 9:59 PM, John R. Sowden
> <[hidden email]> wrote:
>> 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:
> What is the exact error message you received?
> Please copy and paste it here in reply?
>
> Also, what python version do you have?
>
> Thank you.
>
>> ----------------------
>> #/!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
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

John R. Sowden
i just switched to python3 - no difference in error


On 10/22/2017 08:13 PM, John R. Sowden wrote:

> error from terminal program:
> ./sqlite3_test.py: line 6: syntax error near unexpected token `('
> ./sqlite3_test.py: line 6: `connection = sqlite3(':memory:')'
> john@sentry35:~$
>
> version 2.7.12 (ubuntu 16,04 lts)
>
> John
>
>
>
>
> On 10/22/2017 08:07 PM, Igor Korot wrote:
>> Hi, John,
>>
>> On Sun, Oct 22, 2017 at 9:59 PM, John R. Sowden
>> <[hidden email]> wrote:
>>> 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:
>> What is the exact error message you received?
>> Please copy and paste it here in reply?
>>
>> Also, what python version do you have?
>>
>> Thank you.
>>
>>> ----------------------
>>> #/!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
>>> [hidden email]
>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Simon Slavin-3
In reply to this post by John R. Sowden


On 23 Oct 2017, at 4:13am, John R. Sowden <[hidden email]> wrote:

> error from terminal program:
> ./sqlite3_test.py: line 6: syntax error near unexpected token `('
> ./sqlite3_test.py: line 6: `connection = sqlite3(':memory:')'
> john@sentry35:~$

Please make absolutely sure that you are using the quote characters python expects.  Your text editor may have turned apostrophes into smart quotes.

If that’s not the problem then please try replacing that line with

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

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

John R. Sowden
I just checked my file with a hex  editor (ghex) and found they are all
hex 27.

John


On 10/22/2017 08:27 PM, Simon Slavin wrote:

> On 23 Oct 2017, at 4:13am, John R. Sowden <[hidden email]> wrote:
>
>> error from terminal program:
>> ./sqlite3_test.py: line 6: syntax error near unexpected token `('
>> ./sqlite3_test.py: line 6: `connection = sqlite3(':memory:')'
>> john@sentry35:~$
> Please make absolutely sure that you are using the quote characters python expects.  Your text editor may have turned apostrophes into smart quotes.
>
> If that’s not the problem then please try replacing that line with
>
> connection = sqlite3.connect(':memory:')
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Simon Slavin-3


On 23 Oct 2017, at 4:42am, John R. Sowden <[hidden email]> wrote:

> I just checked my file with a hex  editor (ghex) and found they are all hex 27.

Okay, they’re correct.  Try replacing the line it’s complaining about with

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

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

John R. Sowden
^C./sqlite3_test.py: line 7: syntax error near unexpected token `('
./sqlite3_test.py: line 7: `connection = sqlite3.connect(':memory:')'
john@sentry35:~$

On 10/22/2017 08:44 PM, Simon Slavin wrote:
> connection = sqlite3.connect(':memory:')

same
john



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Simon Slavin-3


On 23 Oct 2017, at 4:48am, John R. Sowden <[hidden email]> wrote:

> ^C./sqlite3_test.py: line 7: syntax error near unexpected token `('
> ./sqlite3_test.py: line 7: `connection = sqlite3.connect(':memory:')'
> john@sentry35:~$

Okay, you need someone who knows more about python to help you out.  Hope someone’s reading this thread.

Simon.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Keith Medcalf
In reply to this post by John R. Sowden

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-
>[hidden email]] On Behalf Of John R. Sowden
>Sent: Sunday, 22 October, 2017 20:59
>To: [hidden email]
>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
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

John R. Sowden
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-
>> [hidden email]] On Behalf Of John R. Sowden
>> Sent: Sunday, 22 October, 2017 20:59
>> To: [hidden email]
>> 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
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Keith Medcalf
#!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-
>[hidden email]] On Behalf Of John R. Sowden
>Sent: Sunday, 22 October, 2017 22:24
>To: [hidden email]
>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-
>>> [hidden email]] On Behalf Of John R. Sowden
>>> Sent: Sunday, 22 October, 2017 20:59
>>> To: [hidden email]
>>> 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
>>> [hidden email]
>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>
>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

Simon Slavin-3
In reply to this post by John R. Sowden


On 23 Oct 2017, at 5:24am, John R. Sowden <[hidden email]> wrote:

> i think there are too many errors in this guide for me to use it.

The guide is fine.  You made mistakes when you copied it.

You should be able to copy and past the text straight from the page:

<https://remusao.github.io/posts/2017-10-21-few-tips-sqlite-perf.html>

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: very sqlite3 noobie error

dave
In reply to this post by John R. Sowden
> -----Original Message-----
> From: sqlite-users
> [mailto:[hidden email]] On
> Behalf Of John R. Sowden
> Sent: Sunday, October 22, 2017 9:59 PM
...
> 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.
>
...
If you are trying to 'learn sqlite3' relative to FoxPro, wouldn't you maybe
prefer just experimenting the sqlite command shell?  Then you don't have a
language binding in the way, and can focus on the SQL directly. (I still
usually design/test my queries with the shell, and move them into my product
code after they are doing what I want).

OTOH, if you are trying to learn the programattic API, and not so much the
SQL dialect, then have at it, but I would suggest choosing whatever host
language you are going to build the product in, because all the various
language bindings (except for C) are separate projects and they differ.

Just a thought; cheers
-dave


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users