Comments (4)
You should be able to perform INSERT INTO from any defined dataframe passed to the query function.
tbl = cdf.Table(dataframe=pd.DataFrame({'a': [1, 2, 3], 'b': ['a', 'b', 'c']}))
ret_tbl = tbl.query('INSERT INTO somewhere SELECT * FROM __table__')
from chdb.
Thank you, this is a really smart solution.
from chdb.
It seems I can't access other databases from the table query function. For example, the following code fails with Code: 81. DB::Exception: Database e does not exist. (UNKNOWN_DATABASE)
from chdb.session import Session
import chdb.dataframe as cdf
import pandas as pd
client = Session()
client.query("CREATE DATABASE e ENGINE = Atomic;")
res = client.query(
"CREATE TABLE e.hi (a String primary key, b Int32) Engine = MergeTree ORDER BY a;"
)
df = pd.DataFrame({"a": [str("hi")], "b": [32]})
tbl = cdf.Table(dataframe=df)
h = tbl.query("INSERT INTO e.hi SELECT a, b FROM __table__")
sys.exit(0)
Do you have any ideas how I could access the database from the table query function?
from chdb.
I've managed to make this work using dbapi.
conn = dbapi.connect()
cur = conn.cursor()
cur.execute("CREATE DATABASE e ENGINE = Atomic;")
cur.execute("CREATE TABLE e.hi (a String primary key, b Int32) Engine = MergeTree ORDER BY a;")
cur.execute("INSERT INTO e.hi (a, b) VALUES (%s, %s);", ["test", 32]) # only use %s, not %i or %d etc
cur.execute("SELECT * FROM e.hi;")
res = cur.fetchall()
# res should be [("test", 32)]
With my pull request, you will be able to pass a path
into the dbapi.connect() function like so: dbapi.connect(path="./folder")
. This will enable the same functionality as session, but with using the dbapi.
from chdb.
Related Issues (20)
- Unable to build on arm64 mac HOT 3
- vector analyser of databased blobs in a reactive event driven manner HOT 1
- Add formatQuery from Clickhouse “Other” Functions HOT 1
- Questions regarding zero-copy HOT 4
- Windows support? HOT 1
- Please make chdb available on conda-forge HOT 2
- Unknown output format MsgPack. (UNKNOWN_FORMAT) HOT 1
- CHDB is significantly slower on Arrow tables (in-memory) than with CSV / Parquet HOT 1
- Reimplement the session mode to support Memory engine
- SET clause not work through chDB session
- add sql as an alias for query
- Deno support
- Does chdb supports orm? If supports, how to use? HOT 5
- can support jdbc bridge? HOT 5
- Support for H3 functions HOT 3
- Fail to build with llvm@18 on Mac Arm64 HOT 3
- how to query postgre table?
- how to query postgre table?
- how to query postgre table? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chdb.