Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README updated to reflect the added AUTOINCREMENT type #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ethixkr
Copy link

@ethixkr ethixkr commented Jun 2, 2021

A more conventional way of handling databases. Might confuse some people if the README continues to add primary IDs manually.

@v1a0
Copy link
Owner

v1a0 commented Jun 3, 2021

Hay @ethixkr, thanks for your pull request.

I'm sorry, but code from updated example failing.

Traceback (most recent call last):
  File "test_readme.py", line 15, in <module>
    db.create_table( 'groups'
...
sqlite3.OperationalError: near "AUTOINCREMENT": syntax error

The reason of this issue is column can't be AUTOINCREMENT and UNIQUE at the same time (don't ask me why, it's all apout SQL syntax)

Next fail will be in

groups.insert("User")

It's happening because sqllex sanding database 2 requests, first one:

INSERT INTO groups VALUES 'User'

and it's failed because INSERT VALUES awaiting 2 values. So it's truing create the second one request, sqllex trying insert your value in the first column (due to you don't specified in which column in table inserting this data):

INSERT INTO groups (id) VALUES 'User'

So only one way to code it another way:

groups.insert([None, "User"])

groups.insert(None, 'Guest')

But I'm one sure is this more conventional way. First "None" argument mean you insert nothing in first column.

It passed groups.insert(name="Admin") because in this case you specify for which column this value is.

To see which SQL-scripts executing you can turn on debug mode.

from sqllex.debug import debug_mode

debug_mode(True)

So now I can't merge this pull request. But don't be shy create a new one, when you'll fix this issue :)

P.S.:
Hm, actually I agree, it might be confusing... But don't you think that additional "None" argument in all inserts will be look kind of strange?

@v1a0 v1a0 added the docs Documentation additions or mistakes reports label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation additions or mistakes reports
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants