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

Allow new tables to be created for Ql #30

Closed
tmaiaroto opened this issue Jul 20, 2014 · 4 comments
Closed

Allow new tables to be created for Ql #30

tmaiaroto opened this issue Jul 20, 2014 · 4 comments

Comments

@tmaiaroto
Copy link

In, https://github.com/upper/db/blob/master/ql/database.go ...
I see a bunch of functions, but I don't see how to actually create a table.

I see how you can append to a table (collection), I see that you can empty it, I see you can drop a database, but I just can't see how you create a table.

Is it currently possible? Thanks.

@tmaiaroto
Copy link
Author

...and I've tried

drv := sess.Driver().(*sql.DB)
    rows, err := drv.Query("DROP TABLE IF EXISTS birthdays; CREATE TABLE birthdays (name string, born time)")

...But it can't seem to find sql or ql if I change it to that.

I think this would work for me, but I just need a little more documentation. Thanks.

@tmaiaroto
Copy link
Author

Adding "database/sql" to my import seemed to help...but then

attempt to update the DB outside of a transaction

So I go to use Tx instead:

drv := tx.Driver().(*sql.DB)

and

This action is currently unsupported on this database.

@xiam
Copy link
Member

xiam commented Aug 5, 2014

I'm currently working on fixing transactions with QL.

Related: #25

@xiam
Copy link
Member

xiam commented Oct 7, 2014

Transactions are working in QL again, see: #25

Creating tables using the upper API is not supported and currently not planned, defining the data schema is a developer's responsibility and we should not make any assumptions on such decision.

If for some reason you need to create tables, you should use raw SQL. See the following example:

db/main_test.go

Line 314 in 9ef4a85

_, err = tx.Exec(`CREATE TABLE birthdays (

Also, each adapter has an example on how to use raw SQL: https://upper.io/db/postgresql

@xiam xiam closed this as completed Oct 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants